builderos-cli 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/PUBLISHED.md CHANGED
@@ -3,9 +3,9 @@
3
3
  ## ✅ Package Information
4
4
 
5
5
  **Package name**: `builderos-cli`
6
- **Version**: `2.0.0`
6
+ **Version**: `2.0.3`
7
7
  **Registry**: https://www.npmjs.com/package/builderos-cli
8
- **Published**: 2026-01-14
8
+ **Published**: 2026-01-15
9
9
  **Maintainer**: audilu <khl0327@gmail.com>
10
10
 
11
11
  ## 📦 Installation
@@ -88,10 +88,43 @@ npx builderos-cli init --api-url=YOUR_BUILDEROS_URL
88
88
  ## 📊 Package Stats
89
89
 
90
90
  ```
91
- Size: 6.6 kB (tarball)
92
- Unpacked: 21.5 kB
93
- Dependencies: 0
94
- Files: 6
91
+ Size: 8.7 kB (tarball)
92
+ Unpacked: 28.9 kB
93
+ Dependencies: 1 (@modelcontextprotocol/sdk)
94
+ Files: 8
95
+ ```
96
+
97
+ ## 🆕 Version 2.0.3 Updates
98
+
99
+ **Published**: 2026-01-15
100
+
101
+ **Key Changes**:
102
+ - ✅ Merged MCP server functionality into main CLI package
103
+ - ✅ Added `builderos-cli mcp` subcommand
104
+ - ✅ No longer requires separate `@builderos/mcp-client` package
105
+ - ✅ Added `@modelcontextprotocol/sdk` dependency
106
+ - ✅ Simplified architecture: one package for all functionality
107
+
108
+ **What's New**:
109
+ ```bash
110
+ # New MCP server command (used by .mcp.json)
111
+ npx builderos-cli mcp
112
+ ```
113
+
114
+ **Updated `.mcp.json` format**:
115
+ ```json
116
+ {
117
+ "mcpServers": {
118
+ "builder-os": {
119
+ "type": "stdio",
120
+ "command": "npx",
121
+ "args": ["-y", "builderos-cli", "mcp"],
122
+ "env": {
123
+ "BUILDEROS_API_URL": "http://builder-os.test"
124
+ }
125
+ }
126
+ }
127
+ }
95
128
  ```
96
129
 
97
130
  ## 🔄 Future Updates
package/index.js CHANGED
@@ -9,6 +9,7 @@
9
9
  * Usage:
10
10
  * npx builderos-cli init [options]
11
11
  * npx builderos-cli update [options]
12
+ * npx builderos-cli mcp # Start MCP server
12
13
  *
13
14
  * Options:
14
15
  * --api-url=<url> BuilderOS API URL (default: http://builder-os.test)
@@ -19,12 +20,31 @@
19
20
  */
20
21
 
21
22
  import { mkdir, writeFile, readFile, access } from 'fs/promises';
22
- import { join } from 'path';
23
+ import { join, dirname } from 'path';
23
24
  import { constants } from 'fs';
25
+ import { fileURLToPath } from 'url';
26
+ import { startMCPServer } from './mcp-server.js';
27
+
28
+ // Get package version
29
+ const __filename = fileURLToPath(import.meta.url);
30
+ const __dirname = dirname(__filename);
31
+ const packageJson = JSON.parse(await readFile(join(__dirname, 'package.json'), 'utf-8'));
32
+ const VERSION = packageJson.version;
24
33
 
25
34
  // Parse command line arguments
26
35
  const args = process.argv.slice(2);
27
36
 
37
+ // Check for MCP server command first
38
+ const command = args[0];
39
+ if (command === 'mcp') {
40
+ // Start MCP server (this will run indefinitely)
41
+ await startMCPServer().catch((error) => {
42
+ console.error('Fatal error:', error);
43
+ process.exit(1);
44
+ });
45
+ // MCP server is now running, this code won't be reached
46
+ }
47
+
28
48
  // Default options
29
49
  const options = {
30
50
  apiUrl: process.env.BUILDEROS_API_URL || 'http://builder-os.test',
@@ -35,7 +55,6 @@ const options = {
35
55
  };
36
56
 
37
57
  // Check if first arg is help or no command
38
- const command = args[0];
39
58
  if (!command || command === '--help' || command === '-h') {
40
59
  options.help = true;
41
60
  }
@@ -58,15 +77,17 @@ for (const arg of args) {
58
77
  // Show help
59
78
  if (options.help) {
60
79
  console.log(`
61
- BuilderOS CLI v2.0.0
80
+ BuilderOS CLI v${VERSION}
62
81
 
63
82
  Usage:
64
83
  npx builderos-cli init [options]
65
84
  npx builderos-cli update [options]
85
+ npx builderos-cli mcp
66
86
 
67
87
  Commands:
68
88
  init Initialize BuilderOS in current project
69
89
  update Update skills from BuilderOS API
90
+ mcp Start MCP server (used by Claude Code)
70
91
 
71
92
  Options:
72
93
  --api-url=<url> BuilderOS API URL (default: http://builder-os.test)
@@ -87,6 +108,9 @@ Examples:
87
108
 
88
109
  # Force reinstall
89
110
  npx builderos-cli init --force
111
+
112
+ # Start MCP server (automatically used by .mcp.json)
113
+ npx builderos-cli mcp
90
114
  `);
91
115
  process.exit(0);
92
116
  }
@@ -145,14 +169,13 @@ async function installMCP() {
145
169
  }
146
170
  }
147
171
 
148
- // Always use remote mode (npx @builderos/mcp-client)
149
- // This CLI is meant to be standalone, not requiring local BuilderOS code
172
+ // Use builderos-cli mcp command as MCP server
150
173
  const mcpConfig = {
151
174
  mcpServers: {
152
175
  'builder-os': {
153
176
  type: 'stdio',
154
177
  command: 'npx',
155
- args: ['-y', '@builderos/mcp-client'],
178
+ args: ['-y', 'builderos-cli', 'mcp'],
156
179
  env: {
157
180
  BUILDEROS_API_URL: options.apiUrl,
158
181
  },
@@ -237,10 +260,10 @@ async function createMarker() {
237
260
 
238
261
  const marker = {
239
262
  initialized: true,
240
- version: '2.0.0',
263
+ version: VERSION,
241
264
  timestamp: new Date().toISOString(),
242
265
  architecture: 'api-based',
243
- cli_version: '2.0.0',
266
+ cli_version: VERSION,
244
267
  };
245
268
 
246
269
  await writeFile('.builderos', JSON.stringify(marker, null, 2) + '\n');
@@ -296,7 +319,7 @@ async function updateGitignore() {
296
319
  // Main execution
297
320
  async function main() {
298
321
  console.log('==========================================');
299
- console.log(' BuilderOS CLI v2.0.0');
322
+ console.log(` BuilderOS CLI v${VERSION}`);
300
323
  console.log('==========================================');
301
324
  console.log('');
302
325
  console.log(`Command: ${command}`);
package/mcp-server.js ADDED
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * BuilderOS MCP Server
5
+ *
6
+ * MCP server that connects to BuilderOS HTTP API.
7
+ * Used by Claude Code to access BuilderOS tools.
8
+ */
9
+
10
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
11
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
12
+ import {
13
+ CallToolRequestSchema,
14
+ ListToolsRequestSchema,
15
+ } from '@modelcontextprotocol/sdk/types.js';
16
+
17
+ // Get API URL from environment variable
18
+ const API_URL = process.env.BUILDEROS_API_URL || 'http://builder-os.test';
19
+
20
+ /**
21
+ * Fetch tools from BuilderOS API
22
+ */
23
+ async function fetchTools() {
24
+ try {
25
+ // Only set Host header if API URL is not builder-os.test
26
+ const headers = {};
27
+ if (!API_URL.includes('builder-os.test')) {
28
+ headers['Host'] = 'builder-os.test';
29
+ }
30
+
31
+ const response = await fetch(`${API_URL}/api/mcp/tools`, { headers });
32
+
33
+ if (!response.ok) {
34
+ throw new Error(`Failed to fetch tools: ${response.statusText}`);
35
+ }
36
+
37
+ const data = await response.json();
38
+ return data.tools || [];
39
+ } catch (error) {
40
+ console.error('Error fetching tools:', error);
41
+ return [];
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Execute tool via BuilderOS API
47
+ */
48
+ async function executeTool(toolName, args) {
49
+ try {
50
+ // Only set Host header if API URL is not builder-os.test
51
+ const headers = {
52
+ 'Content-Type': 'application/json',
53
+ };
54
+ if (!API_URL.includes('builder-os.test')) {
55
+ headers['Host'] = 'builder-os.test';
56
+ }
57
+
58
+ const response = await fetch(`${API_URL}/api/mcp/execute`, {
59
+ method: 'POST',
60
+ headers,
61
+ body: JSON.stringify({
62
+ tool: toolName,
63
+ arguments: args
64
+ })
65
+ });
66
+
67
+ if (!response.ok) {
68
+ throw new Error(`Failed to execute tool: ${response.statusText}`);
69
+ }
70
+
71
+ const data = await response.json();
72
+ return data;
73
+ } catch (error) {
74
+ console.error('Error executing tool:', error);
75
+ throw error;
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Start MCP server
81
+ */
82
+ export async function startMCPServer() {
83
+ const server = new Server(
84
+ {
85
+ name: 'builderos-cli-mcp',
86
+ version: '2.0.3',
87
+ },
88
+ {
89
+ capabilities: {
90
+ tools: {},
91
+ },
92
+ }
93
+ );
94
+
95
+ // List available tools
96
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
97
+ const tools = await fetchTools();
98
+ return { tools };
99
+ });
100
+
101
+ // Execute tool
102
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
103
+ const { name, arguments: args } = request.params;
104
+
105
+ try {
106
+ const result = await executeTool(name, args || {});
107
+
108
+ return {
109
+ content: [
110
+ {
111
+ type: 'text',
112
+ text: JSON.stringify(result, null, 2),
113
+ },
114
+ ],
115
+ };
116
+ } catch (error) {
117
+ return {
118
+ content: [
119
+ {
120
+ type: 'text',
121
+ text: `Error: ${error.message}`,
122
+ },
123
+ ],
124
+ isError: true,
125
+ };
126
+ }
127
+ });
128
+
129
+ // Start server
130
+ const transport = new StdioServerTransport();
131
+ await server.connect(transport);
132
+
133
+ console.error('BuilderOS MCP Server started');
134
+ console.error(`Connected to: ${API_URL}`);
135
+ }
136
+
137
+ // Run if called directly
138
+ if (import.meta.url === `file://${process.argv[1]}`) {
139
+ startMCPServer().catch((error) => {
140
+ console.error('Fatal error:', error);
141
+ process.exit(1);
142
+ });
143
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "builderos-cli",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "BuilderOS CLI - Initialize BuilderOS in any project without requiring local code",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -26,5 +26,8 @@
26
26
  "repository": {
27
27
  "type": "git",
28
28
  "url": "https://github.com/builderos/builderos"
29
+ },
30
+ "dependencies": {
31
+ "@modelcontextprotocol/sdk": "^1.0.4"
29
32
  }
30
33
  }