|
| 1 | +--- |
| 2 | +sidebar_position: 1.5 |
| 3 | +sidebar_label: Quickstart |
| 4 | +--- |
| 5 | + |
| 6 | +# Quickstart |
| 7 | + |
| 8 | +This guide will walk you through creating your first Codebolt tool in under 10 minutes. For detailed explanations, see the [complete documentation](./tools.md). |
| 9 | + |
| 10 | +## Prerequisites |
| 11 | + |
| 12 | +- Node.js 14+ installed |
| 13 | +- Codebolt CLI installed: `npm install -g codebolt-cli` |
| 14 | +- Codebolt account (sign up at [portal.codebolt.ai](https://portal.codebolt.ai)) |
| 15 | + |
| 16 | +## Step 1: Login and Create Tool |
| 17 | + |
| 18 | +Go the the main directory of your project and run the following commands: |
| 19 | + |
| 20 | +```bash |
| 21 | +# Login to Codebolt |
| 22 | +npx codebolt-cli login |
| 23 | + |
| 24 | +# Create a new tool |
| 25 | +npx codebolt-cli createtool --name "Hello World Tool" --id "hello-world-tool" |
| 26 | +``` |
| 27 | + |
| 28 | +This will create a new tool directory in the `.codeboltAgents/tools` directory. |
| 29 | + |
| 30 | +```bash |
| 31 | +# Navigate to tool directory |
| 32 | +cd .codeboltAgents/tools/hello-world-tool |
| 33 | +``` |
| 34 | + |
| 35 | + |
| 36 | +## Step 2: Configure Your Tool |
| 37 | + |
| 38 | +The tool details are written in [`codebolttool.yaml`](`codebolttool.yaml`). Edit `codebolttool.yaml`: |
| 39 | + |
| 40 | +```yaml |
| 41 | +name: "Hello World Tool" |
| 42 | +description: "A simple greeting tool" |
| 43 | +version: "1.0.0" |
| 44 | +uniqueName: "hello-world-tool" |
| 45 | + |
| 46 | +parameters: |
| 47 | + name: |
| 48 | + type: "string" |
| 49 | + description: "Name to greet" |
| 50 | + default: "World" |
| 51 | +``` |
| 52 | +
|
| 53 | +## Step 3: Implement Tool Logic |
| 54 | +
|
| 55 | +The Tool Logic is written using [ToolBox class](./tools.md#toolbox-class). Replace `index.js` content: |
| 56 | + |
| 57 | +```javascript |
| 58 | +const { ToolBox } = require('@codebolt/toolbox'); |
| 59 | +
|
| 60 | +class HelloWorldTool { |
| 61 | + constructor(config) { |
| 62 | + this.toolbox = new ToolBox({ |
| 63 | + name: 'Hello World Tool', |
| 64 | + version: '1.0.0' |
| 65 | + }); |
| 66 | + |
| 67 | + this.setupTools(); |
| 68 | + } |
| 69 | +
|
| 70 | + setupTools() { |
| 71 | + this.toolbox.addTool({ |
| 72 | + name: 'greet', |
| 73 | + description: 'Generate a greeting message', |
| 74 | + parameters: { |
| 75 | + name: { |
| 76 | + type: 'string', |
| 77 | + description: 'Name to greet', |
| 78 | + default: 'World' |
| 79 | + } |
| 80 | + }, |
| 81 | + execute: this.greet.bind(this) |
| 82 | + }); |
| 83 | + } |
| 84 | +
|
| 85 | + async greet(args, context) { |
| 86 | + const { name = 'World' } = args; |
| 87 | + |
| 88 | + context.log.info(`Generating greeting for ${name}`); |
| 89 | + |
| 90 | + return { |
| 91 | + message: `Hello, ${name}!`, |
| 92 | + timestamp: new Date().toISOString() |
| 93 | + }; |
| 94 | + } |
| 95 | + |
| 96 | + async start() { |
| 97 | + await this.toolbox.start(); |
| 98 | + } |
| 99 | +} |
| 100 | + |
| 101 | +module.exports = HelloWorldTool; |
| 102 | +``` |
| 103 | + |
| 104 | +## Step 4: Test Your Tool |
| 105 | + |
| 106 | +[Codebolt CLI](../cli/overview.md) provides a way to test the tool locally. |
| 107 | + |
| 108 | +```bash |
| 109 | +# Test the greet function |
| 110 | +npx codebolt-cli runtool greet ./index.js |
| 111 | + |
| 112 | +# When prompted, enter: {"name": "Developer"} |
| 113 | +# Expected output: {"message": "Hello, Developer!", "timestamp": "..."} |
| 114 | +``` |
| 115 | + |
| 116 | +You can also use the interactive inspector to debug the tool. |
| 117 | +```bash |
| 118 | +# Use interactive inspector for debugging |
| 119 | +npx codebolt-cli inspecttool ./index.js |
| 120 | +``` |
| 121 | + |
| 122 | +## Step 5: Test Your Tool in Codebolt Application |
| 123 | + |
| 124 | +Open the Codebolt Application and open the current project. |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | +## Step 6: Publish Your Tool |
| 129 | + |
| 130 | +```bash |
| 131 | +# Publish to registry |
| 132 | +codebolt-cli publishtool |
| 133 | + |
| 134 | +# Follow the prompts: |
| 135 | +# - GitHub URL (optional) |
| 136 | +# - Category: "Utility" |
| 137 | +# - Tags: "greeting,hello,demo" |
| 138 | +# - Requires API key: No |
| 139 | +``` |
| 140 | + |
| 141 | +## Step 7: Use Your Tool |
| 142 | + |
| 143 | +```bash |
| 144 | +# Install your published tool |
| 145 | +codebolt-cli installtool hello-world-tool |
| 146 | + |
| 147 | +# Use in another project |
| 148 | +codebolt-cli runtool greet hello-world-tool |
| 149 | +``` |
| 150 | + |
| 151 | +## Quick Commands Reference |
| 152 | + |
| 153 | +```bash |
| 154 | +# Tool Management |
| 155 | +codebolt-cli createtool # Create new tool |
| 156 | +codebolt-cli runtool <function> <file> # Test tool function |
| 157 | +codebolt-cli inspecttool <file> # Debug tool interactively |
| 158 | +codebolt-cli publishtool # Publish to registry |
| 159 | + |
| 160 | +# Registry Operations |
| 161 | +codebolt-cli searchtools <query> # Search tools |
| 162 | +codebolt-cli installtool <tool-name> # Install tool |
| 163 | +codebolt-cli listtools --installed # List installed tools |
| 164 | +codebolt-cli updatetool <tool-name> # Update tool |
| 165 | +``` |
| 166 | + |
| 167 | +## Example Use Cases |
| 168 | + |
| 169 | +### API Integration Tool |
| 170 | +```bash |
| 171 | +codebolt-cli createtool --name "Weather Tool" --id "weather-tool" |
| 172 | +# Add API key parameter and fetch weather data |
| 173 | +``` |
| 174 | + |
| 175 | +### File Processing Tool |
| 176 | +```bash |
| 177 | +codebolt-cli createtool --name "CSV Parser" --id "csv-parser" |
| 178 | +# Add file reading and CSV parsing logic |
| 179 | +``` |
| 180 | + |
| 181 | +### Data Transformation Tool |
| 182 | +```bash |
| 183 | +codebolt-cli createtool --name "JSON Formatter" --id "json-formatter" |
| 184 | +# Add JSON validation and formatting functions |
| 185 | +``` |
| 186 | + |
| 187 | +## Next Steps |
| 188 | + |
| 189 | +Now that you've created your first tool, explore: |
| 190 | + |
| 191 | +- **[Complete Tools Guide](./tools.md)** - Detailed concepts and patterns |
| 192 | +- **[Testing Guide](./testlocalmcp.md)** - Comprehensive testing strategies |
| 193 | +- **[Publishing Guide](./publish_tool.md)** - Advanced publishing features |
| 194 | +- **[Tool Registry](./tool_registry.md)** - Discover and manage tools |
| 195 | + |
| 196 | +## Troubleshooting |
| 197 | + |
| 198 | +**Tool not working?** |
| 199 | +```bash |
| 200 | +# Check configuration |
| 201 | +cat codebolttool.yaml |
| 202 | + |
| 203 | +# Validate tool |
| 204 | +codebolt-cli runtool greet ./index.js |
| 205 | +``` |
| 206 | + |
| 207 | +**Publishing failed?** |
| 208 | +```bash |
| 209 | +# Check authentication |
| 210 | +codebolt-cli whoami |
| 211 | + |
| 212 | +# Verify unique name |
| 213 | +codebolt-cli searchtools hello-world-tool |
| 214 | +``` |
| 215 | + |
| 216 | +**Need help?** |
| 217 | +```bash |
| 218 | +# Get help |
| 219 | +codebolt-cli help |
| 220 | + |
| 221 | +# Check tool status |
| 222 | +codebolt-cli toolstatus hello-world-tool |
| 223 | +``` |
| 224 | + |
| 225 | +--- |
| 226 | + |
| 227 | +🎉 **Congratulations!** You've created, tested, and published your first Codebolt tool. Start building more complex tools by exploring the detailed documentation. |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | + |
0 commit comments