@ottocode/server 0.1.201 → 0.1.202
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/package.json +3 -3
- package/src/routes/mcp.ts +34 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ottocode/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.202",
|
|
4
4
|
"description": "HTTP API server for ottocode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"typecheck": "tsc --noEmit"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@ottocode/sdk": "0.1.
|
|
53
|
-
"@ottocode/database": "0.1.
|
|
52
|
+
"@ottocode/sdk": "0.1.202",
|
|
53
|
+
"@ottocode/database": "0.1.202",
|
|
54
54
|
"drizzle-orm": "^0.44.5",
|
|
55
55
|
"hono": "^4.9.9",
|
|
56
56
|
"zod": "^4.1.8"
|
package/src/routes/mcp.ts
CHANGED
|
@@ -29,6 +29,7 @@ export function registerMCPRoutes(app: Hono) {
|
|
|
29
29
|
tools: status?.tools ?? [],
|
|
30
30
|
authRequired: status?.authRequired ?? false,
|
|
31
31
|
authenticated: status?.authenticated ?? false,
|
|
32
|
+
scope: s.scope ?? 'global',
|
|
32
33
|
};
|
|
33
34
|
});
|
|
34
35
|
|
|
@@ -39,7 +40,8 @@ export function registerMCPRoutes(app: Hono) {
|
|
|
39
40
|
const projectRoot = process.cwd();
|
|
40
41
|
const body = await c.req.json();
|
|
41
42
|
|
|
42
|
-
const { name, transport, command, args, env, url, headers, oauth } =
|
|
43
|
+
const { name, transport, command, args, env, url, headers, oauth, scope } =
|
|
44
|
+
body;
|
|
43
45
|
if (!name) {
|
|
44
46
|
return c.json({ ok: false, error: 'name is required' }, 400);
|
|
45
47
|
}
|
|
@@ -51,6 +53,16 @@ export function registerMCPRoutes(app: Hono) {
|
|
|
51
53
|
400,
|
|
52
54
|
);
|
|
53
55
|
}
|
|
56
|
+
if (t === 'stdio' && command && /^https?:\/\//i.test(String(command))) {
|
|
57
|
+
return c.json(
|
|
58
|
+
{
|
|
59
|
+
ok: false,
|
|
60
|
+
error:
|
|
61
|
+
'stdio transport requires a local command, not a URL. Use http or sse transport for remote servers.',
|
|
62
|
+
},
|
|
63
|
+
400,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
54
66
|
if ((t === 'http' || t === 'sse') && !url) {
|
|
55
67
|
return c.json(
|
|
56
68
|
{ ok: false, error: 'url is required for http/sse transport' },
|
|
@@ -58,9 +70,12 @@ export function registerMCPRoutes(app: Hono) {
|
|
|
58
70
|
);
|
|
59
71
|
}
|
|
60
72
|
|
|
73
|
+
const serverScope = scope === 'project' ? 'project' : 'global';
|
|
74
|
+
|
|
61
75
|
const serverConfig = {
|
|
62
76
|
name: String(name),
|
|
63
77
|
transport: t,
|
|
78
|
+
scope: serverScope as 'global' | 'project',
|
|
64
79
|
...(command ? { command: String(command) } : {}),
|
|
65
80
|
...(Array.isArray(args) ? { args: args.map(String) } : {}),
|
|
66
81
|
...(env && typeof env === 'object' ? { env } : {}),
|
|
@@ -70,7 +85,11 @@ export function registerMCPRoutes(app: Hono) {
|
|
|
70
85
|
};
|
|
71
86
|
|
|
72
87
|
try {
|
|
73
|
-
await addMCPServerToConfig(
|
|
88
|
+
await addMCPServerToConfig(
|
|
89
|
+
projectRoot,
|
|
90
|
+
serverConfig,
|
|
91
|
+
getGlobalConfigDir(),
|
|
92
|
+
);
|
|
74
93
|
return c.json({ ok: true, server: serverConfig });
|
|
75
94
|
} catch (err) {
|
|
76
95
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -88,7 +107,11 @@ export function registerMCPRoutes(app: Hono) {
|
|
|
88
107
|
await manager.stopServer(name);
|
|
89
108
|
}
|
|
90
109
|
|
|
91
|
-
const removed = await removeMCPServerFromConfig(
|
|
110
|
+
const removed = await removeMCPServerFromConfig(
|
|
111
|
+
projectRoot,
|
|
112
|
+
name,
|
|
113
|
+
getGlobalConfigDir(),
|
|
114
|
+
);
|
|
92
115
|
if (!removed) {
|
|
93
116
|
return c.json({ ok: false, error: `Server "${name}" not found` }, 404);
|
|
94
117
|
}
|
|
@@ -112,7 +135,10 @@ export function registerMCPRoutes(app: Hono) {
|
|
|
112
135
|
try {
|
|
113
136
|
let manager = getMCPManager();
|
|
114
137
|
if (!manager) {
|
|
115
|
-
manager = await initializeMCP({ servers: [] });
|
|
138
|
+
manager = await initializeMCP({ servers: [] }, projectRoot);
|
|
139
|
+
}
|
|
140
|
+
if (!manager.started) {
|
|
141
|
+
manager.setProjectRoot(projectRoot);
|
|
116
142
|
}
|
|
117
143
|
await manager.restartServer(serverConfig);
|
|
118
144
|
const status = (await manager.getStatusAsync()).find(
|
|
@@ -162,7 +188,10 @@ export function registerMCPRoutes(app: Hono) {
|
|
|
162
188
|
try {
|
|
163
189
|
let manager = getMCPManager();
|
|
164
190
|
if (!manager) {
|
|
165
|
-
manager = await initializeMCP({ servers: [] });
|
|
191
|
+
manager = await initializeMCP({ servers: [] }, projectRoot);
|
|
192
|
+
}
|
|
193
|
+
if (!manager.started) {
|
|
194
|
+
manager.setProjectRoot(projectRoot);
|
|
166
195
|
}
|
|
167
196
|
|
|
168
197
|
const authUrl = await manager.initiateAuth(serverConfig);
|