Skip to content

Commit 5bee251

Browse files
committed
Merge branch 'main' of https://github.com/codeboltai/cli
2 parents 473c1e4 + cfd4fc0 commit 5bee251

File tree

8 files changed

+3534
-803
lines changed

8 files changed

+3534
-803
lines changed

README.md

Lines changed: 164 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,177 @@ A powerful command-line interface for creating, managing, and deploying Codebolt
77
```bash
88
# Install globally
99
npm install -g codebolt-cli
10+
```
1011

11-
# Verify installation
12-
codebolt-cli version
12+
## Authentication
13+
Before using most features, you'll need to authenticate:
1314

14-
# Login to your account
15+
```bash
1516
codebolt-cli login
17+
```
18+
19+
To logout:
20+
```bash
21+
codebolt-cli logout
22+
```
23+
24+
## Commands
25+
26+
### Version
27+
Check the application version:
28+
```bash
29+
codebolt-cli version
30+
```
31+
32+
### Agent Management
33+
34+
#### Create Agent
35+
Create a new Codebolt Agent:
36+
```bash
37+
codebolt-cli createagent
38+
codebolt-cli createagent -n "MyAgent" --quick
39+
```
40+
41+
#### Publish Agent
42+
Publish an agent to the registry:
43+
```bash
44+
codebolt-cli publishagent [folderPath]
45+
```
46+
47+
#### List Agents
48+
List all agents created and uploaded by you:
49+
```bash
50+
codebolt-cli listagents
51+
```
52+
53+
#### Start Agent
54+
Start an agent in the specified working directory:
55+
```bash
56+
codebolt-cli startagent [workingDir]
57+
```
58+
59+
#### Pull Agent
60+
Pull the latest agent configuration from server:
61+
```bash
62+
codebolt-cli pullagent [workingDir]
63+
```
64+
65+
#### Clone Agent
66+
Clone an agent using its unique_id:
67+
```bash
68+
codebolt-cli cloneagent <unique_id> [targetDir]
69+
```
70+
71+
### MCP Tool Management
72+
73+
#### Create Tool
74+
Create a new MCP (Model Context Protocol) tool:
75+
```bash
76+
codebolt-cli createtool
77+
codebolt-cli createtool -n "MyTool" -i "my-tool-id" -d "Tool description"
78+
```
1679

17-
# Create your first agent
18-
codebolt-cli createagent --name "My First Agent"
80+
Options:
81+
- `-n, --name <name>`: Name of the tool
82+
- `-i, --id <unique-id>`: Unique identifier (no spaces)
83+
- `-d, --description <description>`: Description of the tool
84+
- `-p, --parameters <json>`: Tool parameters in JSON format
1985

20-
# Create a tool
21-
codebolt-cli createtool --name "File Helper" --id "file-helper"
86+
#### Publish Tool
87+
Publish an MCP tool to the registry:
88+
```bash
89+
codebolt-cli publishtool [folderPath]
90+
```
91+
92+
This command will:
93+
- Read the `codebolttool.yaml` configuration file
94+
- Package and upload the tool's source code
95+
- Register the tool in the MCP registry
96+
- Handle both new tool creation and updates
97+
98+
**Requirements for publishing:**
99+
- A `codebolttool.yaml` file must be present in the tool directory
100+
- Required fields in `codebolttool.yaml`: `name`, `uniqueName`, `description`
101+
102+
**Interactive prompts for new tools:**
103+
- GitHub repository URL (optional)
104+
- Category selection
105+
- Tags (comma-separated)
106+
- API key requirement
107+
108+
#### List Tools
109+
List all MCP tools published by you:
110+
```bash
111+
codebolt-cli listtools
112+
```
113+
114+
#### Pull Tools
115+
Pull the latest MCP tool configuration from server:
116+
```bash
117+
codebolt-cli pulltools [workingDir]
118+
```
119+
120+
This command will:
121+
- Read your local `codebolttool.yaml` file
122+
- Fetch the latest configuration from the server
123+
- Compare versions and prompt for confirmation if needed
124+
- Update your local configuration file
125+
126+
#### Run Tool
127+
Run a specified tool with a file:
128+
```bash
129+
codebolt-cli runtool <command> <file>
130+
```
131+
132+
#### Inspect Tool
133+
Inspect a server file using the MCP inspector:
134+
```bash
135+
codebolt-cli inspecttool <file>
136+
```
137+
138+
## MCP Tool Configuration
139+
140+
When creating or publishing MCP tools, ensure your `codebolttool.yaml` file contains:
141+
142+
```yaml
143+
name: "My MCP Tool"
144+
uniqueName: "my-mcp-tool"
145+
description: "Description of what this tool does"
146+
version: "1.0.0"
147+
parameters:
148+
param1: "value1"
149+
param2: "value2"
150+
```
151+
152+
## File Structure
153+
154+
### For Agents
155+
Agents should contain a `codeboltagent.yaml` configuration file.
156+
157+
### For MCP Tools
158+
MCP tools should contain a `codebolttool.yaml` configuration file and follow the MCP protocol standards.
159+
160+
## Examples
161+
162+
### Publishing a new MCP tool:
163+
```bash
164+
cd my-mcp-tool-directory
165+
codebolt-cli publishtool
22166
```
23167

24-
## 📋 Features
168+
### Updating an existing MCP tool:
169+
```bash
170+
cd my-existing-tool
171+
codebolt-cli publishtool
172+
```
173+
174+
The CLI will automatically detect if it's an update based on the `uniqueName` in your configuration.
175+
176+
## Error Handling
177+
The CLI provides detailed error messages and colored output for better user experience. Make sure you're authenticated and have the required configuration files before running publish commands.
178+
179+
## Author
180+
Codebolt Team
25181

26182
### Agent Management
27183
- **Create Agents**: Interactive wizard for agent creation

actions/listTools.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
const chalk = require('chalk');
2+
const axios = require('axios');
3+
const { checkUserAuth, getUserData } = require('./userData');
4+
5+
// MCP API endpoints - adjust these based on your actual API base URL
6+
const MCP_API_BASE = 'https://api.codebolt.ai'; // Update this to your actual MCP API base URL
7+
8+
const listTools = async () => {
9+
// Check if the user is logged in
10+
if (!checkUserAuth()) {
11+
console.log(chalk.red('User not authenticated. Please login first.'));
12+
return;
13+
}
14+
15+
try {
16+
const data = getUserData();
17+
const authToken = data.jwtToken;
18+
19+
// Get current user's username
20+
let username;
21+
try {
22+
const getUsernameResponse = await axios.get(
23+
`${MCP_API_BASE}/api/auth/check-username`,
24+
{ headers: { 'Authorization': `Bearer ${authToken}` } }
25+
);
26+
username = getUsernameResponse.data.usersData[0].username;
27+
} catch (err) {
28+
throw new Error(`Failed to get username: ${err.message}`);
29+
}
30+
31+
console.log(chalk.blue('📦 Fetching your published MCP tools...\n'));
32+
33+
// Fetch user's MCP tools
34+
try {
35+
const response = await axios.get(
36+
`${MCP_API_BASE}/mcp/myMcp/${username}`,
37+
{
38+
headers: {
39+
'Authorization': `Bearer ${authToken}`,
40+
'x-codebolt-userId': data.userId
41+
}
42+
}
43+
);
44+
45+
const tools = response.data.data || [];
46+
47+
if (tools.length === 0) {
48+
console.log(chalk.yellow('📭 No MCP tools found. Use "codebolt-cli publishtool" to publish your first tool!'));
49+
return;
50+
}
51+
52+
console.log(chalk.green(`✅ Found ${tools.length} published MCP tool(s):\n`));
53+
54+
// Display tools in a formatted way
55+
tools.forEach((tool, index) => {
56+
console.log(chalk.cyan(`${index + 1}. ${tool.name}`));
57+
console.log(chalk.gray(` ID: ${tool.mcpId}`));
58+
console.log(chalk.gray(` Description: ${tool.description || 'No description'}`));
59+
60+
if (tool.category) {
61+
console.log(chalk.gray(` Category: ${tool.category}`));
62+
}
63+
64+
if (tool.tags) {
65+
console.log(chalk.gray(` Tags: ${tool.tags}`));
66+
}
67+
68+
if (tool.githubUrl) {
69+
console.log(chalk.gray(` GitHub: ${tool.githubUrl}`));
70+
}
71+
72+
if (tool.githubStars) {
73+
console.log(chalk.gray(` ⭐ Stars: ${tool.githubStars}`));
74+
}
75+
76+
if (tool.requiresApiKey) {
77+
console.log(chalk.gray(` 🔑 Requires API Key: Yes`));
78+
}
79+
80+
console.log(chalk.gray(` 📅 Updated: ${new Date(tool.updatedAt).toLocaleDateString()}`));
81+
console.log(); // Empty line for spacing
82+
});
83+
84+
console.log(chalk.blue(`💡 Use "codebolt-cli publishtool <folder>" to update an existing tool or publish a new one.`));
85+
86+
} catch (err) {
87+
if (err.response && err.response.status === 404) {
88+
console.log(chalk.yellow('📭 No MCP tools found. Use "codebolt-cli publishtool" to publish your first tool!'));
89+
return;
90+
}
91+
throw new Error(`Failed to fetch MCP tools: ${err.response?.data?.error || err.message}`);
92+
}
93+
94+
} catch (error) {
95+
console.error(chalk.red('❌ Error fetching tools:'), error.message);
96+
process.exit(1);
97+
}
98+
};
99+
100+
module.exports = { listTools };

0 commit comments

Comments
 (0)