Skip to content

Commit a3d2a05

Browse files
committed
add publish tool and pull tools
1 parent 5f8814e commit a3d2a05

File tree

8 files changed

+2558
-13
lines changed

8 files changed

+2558
-13
lines changed

README.md

Lines changed: 168 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,184 @@
11
# Codebolt CLI Tool
22

33
## Description
4-
Codebolt is a CLI tool created using Node.js. It allows users to check the application version and upload folders to a specified server.
4+
Codebolt is a comprehensive CLI tool created using Node.js. It allows developers to create, manage, and publish AI agents and MCP (Model Context Protocol) tools, along with various utility functions for development.
55

66
## Installation
7-
To install Codebolt CLI tool locally, ensure you have Node.js and npm installed, then run:
7+
To install Codebolt CLI tool globally, ensure you have Node.js and npm installed, then run:
88

9+
```bash
910
npm install -g codebolt-cli
11+
```
1012

11-
## Usage
13+
## Authentication
14+
Before using most features, you'll need to authenticate:
1215

13-
### Check Version
14-
To check the application version, run:
15-
codebolt version
16+
```bash
17+
codebolt-cli login
18+
```
1619

17-
### Upload Folder
18-
To upload a folder to the server, run:
19-
codebolt upload <folderPath>
20+
To logout:
21+
```bash
22+
codebolt-cli logout
23+
```
2024

21-
Replace `<folderPath>` with the path to the folder you want to upload.
25+
## Commands
26+
27+
### Version
28+
Check the application version:
29+
```bash
30+
codebolt-cli version
31+
```
32+
33+
### Agent Management
34+
35+
#### Create Agent
36+
Create a new Codebolt Agent:
37+
```bash
38+
codebolt-cli createagent
39+
codebolt-cli createagent -n "MyAgent" --quick
40+
```
41+
42+
#### Publish Agent
43+
Publish an agent to the registry:
44+
```bash
45+
codebolt-cli publishagent [folderPath]
46+
```
47+
48+
#### List Agents
49+
List all agents created and uploaded by you:
50+
```bash
51+
codebolt-cli listagents
52+
```
53+
54+
#### Start Agent
55+
Start an agent in the specified working directory:
56+
```bash
57+
codebolt-cli startagent [workingDir]
58+
```
59+
60+
#### Pull Agent
61+
Pull the latest agent configuration from server:
62+
```bash
63+
codebolt-cli pullagent [workingDir]
64+
```
65+
66+
#### Clone Agent
67+
Clone an agent using its unique_id:
68+
```bash
69+
codebolt-cli cloneagent <unique_id> [targetDir]
70+
```
71+
72+
### MCP Tool Management
73+
74+
#### Create Tool
75+
Create a new MCP (Model Context Protocol) tool:
76+
```bash
77+
codebolt-cli createtool
78+
codebolt-cli createtool -n "MyTool" -i "my-tool-id" -d "Tool description"
79+
```
80+
81+
Options:
82+
- `-n, --name <name>`: Name of the tool
83+
- `-i, --id <unique-id>`: Unique identifier (no spaces)
84+
- `-d, --description <description>`: Description of the tool
85+
- `-p, --parameters <json>`: Tool parameters in JSON format
86+
87+
#### Publish Tool
88+
Publish an MCP tool to the registry:
89+
```bash
90+
codebolt-cli publishtool [folderPath]
91+
```
92+
93+
This command will:
94+
- Read the `codebolttool.yaml` configuration file
95+
- Package and upload the tool's source code
96+
- Register the tool in the MCP registry
97+
- Handle both new tool creation and updates
98+
99+
**Requirements for publishing:**
100+
- A `codebolttool.yaml` file must be present in the tool directory
101+
- Required fields in `codebolttool.yaml`: `name`, `uniqueName`, `description`
102+
103+
**Interactive prompts for new tools:**
104+
- GitHub repository URL (optional)
105+
- Category selection
106+
- Tags (comma-separated)
107+
- API key requirement
108+
109+
#### List Tools
110+
List all MCP tools published by you:
111+
```bash
112+
codebolt-cli listtools
113+
```
114+
115+
#### Pull Tools
116+
Pull the latest MCP tool configuration from server:
117+
```bash
118+
codebolt-cli pulltools [workingDir]
119+
```
120+
121+
This command will:
122+
- Read your local `codebolttool.yaml` file
123+
- Fetch the latest configuration from the server
124+
- Compare versions and prompt for confirmation if needed
125+
- Update your local configuration file
126+
127+
#### Run Tool
128+
Run a specified tool with a file:
129+
```bash
130+
codebolt-cli runtool <command> <file>
131+
```
132+
133+
#### Inspect Tool
134+
Inspect a server file using the MCP inspector:
135+
```bash
136+
codebolt-cli inspecttool <file>
137+
```
138+
139+
## MCP Tool Configuration
140+
141+
When creating or publishing MCP tools, ensure your `codebolttool.yaml` file contains:
142+
143+
```yaml
144+
name: "My MCP Tool"
145+
uniqueName: "my-mcp-tool"
146+
description: "Description of what this tool does"
147+
version: "1.0.0"
148+
parameters:
149+
param1: "value1"
150+
param2: "value2"
151+
```
152+
153+
## File Structure
154+
155+
### For Agents
156+
Agents should contain a `codeboltagent.yaml` configuration file.
157+
158+
### For MCP Tools
159+
MCP tools should contain a `codebolttool.yaml` configuration file and follow the MCP protocol standards.
160+
161+
## Examples
162+
163+
### Publishing a new MCP tool:
164+
```bash
165+
cd my-mcp-tool-directory
166+
codebolt-cli publishtool
167+
```
168+
169+
### Updating an existing MCP tool:
170+
```bash
171+
cd my-existing-tool
172+
codebolt-cli publishtool
173+
```
174+
175+
The CLI will automatically detect if it's an update based on the `uniqueName` in your configuration.
176+
177+
## Error Handling
178+
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.
22179

23180
## Author
24-
Your Name
181+
Codebolt Team
25182

26183
## License
27184
ISC

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)