@contextual-io/cli 0.7.1 → 0.8.1
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/README.md +52 -1
- package/dist/base.js +7 -1
- package/dist/commands/mcp/index.d.ts +11 -0
- package/dist/commands/mcp/index.js +25 -0
- package/dist/commands/mcp/serve.d.ts +17 -0
- package/dist/commands/mcp/serve.js +124 -0
- package/dist/mcp/bridge-manager.d.ts +29 -0
- package/dist/mcp/bridge-manager.js +260 -0
- package/dist/mcp/contracts.d.ts +43 -0
- package/dist/mcp/contracts.js +27 -0
- package/dist/mcp/http-server.d.ts +45 -0
- package/dist/mcp/http-server.js +242 -0
- package/dist/mcp/logger.d.ts +4 -0
- package/dist/mcp/logger.js +9 -0
- package/dist/mcp/runtime.d.ts +24 -0
- package/dist/mcp/runtime.js +297 -0
- package/dist/mcp/server.d.ts +90 -0
- package/dist/mcp/server.js +308 -0
- package/dist/mcp/session.d.ts +42 -0
- package/dist/mcp/session.js +75 -0
- package/dist/mcp/socket-bridge.d.ts +67 -0
- package/dist/mcp/socket-bridge.js +357 -0
- package/dist/models/mcp.d.ts +288 -0
- package/dist/models/mcp.js +137 -0
- package/dist/utils/endpoints.d.ts +1 -0
- package/dist/utils/endpoints.js +1 -0
- package/oclif.manifest.json +116 -1
- package/package.json +5 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* WARNING: This is a shared, external API contract.
|
|
3
|
+
*/
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
export const McpSessionId = z.string();
|
|
6
|
+
export const McpDetachReason = z.enum([
|
|
7
|
+
"target-disconnected",
|
|
8
|
+
"mcp-disconnected",
|
|
9
|
+
"manual-detach",
|
|
10
|
+
]);
|
|
11
|
+
export const McpBindFailureCode = z.enum([
|
|
12
|
+
"MCP_DISABLED",
|
|
13
|
+
"NO_ACTIVE_BROWSER",
|
|
14
|
+
"BIND_DENIED",
|
|
15
|
+
"INTERNAL_ERROR",
|
|
16
|
+
]);
|
|
17
|
+
export const McpToolErrorCode = z.enum([
|
|
18
|
+
"NOT_ATTACHED",
|
|
19
|
+
"UNKNOWN_TOOL",
|
|
20
|
+
"COMMAND_IN_FLIGHT",
|
|
21
|
+
"TIMEOUT",
|
|
22
|
+
"UNAUTHORIZED",
|
|
23
|
+
"INTERNAL_ERROR",
|
|
24
|
+
]);
|
|
25
|
+
export const JsonSchema = z.record(z.string(), z.unknown());
|
|
26
|
+
export const McpToolDefinition = z.object({
|
|
27
|
+
annotations: z.record(z.string(), z.unknown()).optional(),
|
|
28
|
+
description: z.string(),
|
|
29
|
+
inputSchema: JsonSchema,
|
|
30
|
+
name: z.string(),
|
|
31
|
+
outputSchema: JsonSchema.optional(),
|
|
32
|
+
title: z.string().optional(),
|
|
33
|
+
});
|
|
34
|
+
export const McpClientPackageInfo = z.object({
|
|
35
|
+
name: z.string().optional(),
|
|
36
|
+
version: z.string().optional(),
|
|
37
|
+
});
|
|
38
|
+
export const McpManifestRequest = z.object({
|
|
39
|
+
interfaceType: z.string(),
|
|
40
|
+
});
|
|
41
|
+
export const McpManifestResponse = z.object({
|
|
42
|
+
definitions: z.array(McpToolDefinition),
|
|
43
|
+
interfaceType: z.string(),
|
|
44
|
+
resolvedAt: z.number().int(),
|
|
45
|
+
tools: z.array(z.string()),
|
|
46
|
+
});
|
|
47
|
+
export const McpFlowSession = z.object({
|
|
48
|
+
flowId: z.string(),
|
|
49
|
+
flowName: z.string(),
|
|
50
|
+
});
|
|
51
|
+
export const McpListSessionsRequest = z.object({
|
|
52
|
+
flowId: z.string().optional(),
|
|
53
|
+
interfaceType: z.string(),
|
|
54
|
+
});
|
|
55
|
+
export const McpListSessionsResponse = z.object({
|
|
56
|
+
sessions: z.array(McpFlowSession),
|
|
57
|
+
});
|
|
58
|
+
export const McpBindSessionRequest = z.object({
|
|
59
|
+
flowId: z.string(),
|
|
60
|
+
});
|
|
61
|
+
export const McpBindSessionResponse = z.object({
|
|
62
|
+
boundAt: z.number().int(),
|
|
63
|
+
flowId: z.string(),
|
|
64
|
+
flowName: z.string(),
|
|
65
|
+
});
|
|
66
|
+
export const McpBindSessionFailure = z.object({
|
|
67
|
+
code: McpBindFailureCode,
|
|
68
|
+
message: z.string(),
|
|
69
|
+
sessions: z.array(McpFlowSession).optional(),
|
|
70
|
+
});
|
|
71
|
+
export const McpSessionControlRequest = z.object({
|
|
72
|
+
mcpSessionId: McpSessionId,
|
|
73
|
+
});
|
|
74
|
+
export const McpSessionDisconnectAck = z.object({
|
|
75
|
+
detachedAt: z.number().int().optional(),
|
|
76
|
+
});
|
|
77
|
+
export const McpToolRegistrySync = z.object({
|
|
78
|
+
action: z.enum(["register", "clear"]),
|
|
79
|
+
clientPackage: McpClientPackageInfo.optional(),
|
|
80
|
+
definitions: z.array(McpToolDefinition),
|
|
81
|
+
expertId: z.string().optional(),
|
|
82
|
+
expertName: z.string().optional(),
|
|
83
|
+
mcpSessionId: McpSessionId,
|
|
84
|
+
replace: z.boolean().optional(),
|
|
85
|
+
tools: z.array(z.string()),
|
|
86
|
+
updatedAt: z.number().int(),
|
|
87
|
+
});
|
|
88
|
+
export const McpToolCall = z.object({
|
|
89
|
+
args: z.record(z.string(), z.unknown()),
|
|
90
|
+
name: z.string(),
|
|
91
|
+
timeoutMs: z.number().int().optional(),
|
|
92
|
+
type: z.literal("mcp-tool"),
|
|
93
|
+
});
|
|
94
|
+
export const McpToolProgress = z.object({
|
|
95
|
+
data: z.unknown().optional(),
|
|
96
|
+
message: z.string().optional(),
|
|
97
|
+
percent: z.number().optional(),
|
|
98
|
+
});
|
|
99
|
+
export const McpToolResult = z.object({
|
|
100
|
+
commandId: z.string(),
|
|
101
|
+
result: z.unknown(),
|
|
102
|
+
});
|
|
103
|
+
export const McpToolError = z.object({
|
|
104
|
+
code: McpToolErrorCode.optional(),
|
|
105
|
+
data: z.unknown().optional(),
|
|
106
|
+
message: z.string(),
|
|
107
|
+
});
|
|
108
|
+
export const McpCommandStatusType = z.enum([
|
|
109
|
+
"accepted",
|
|
110
|
+
"dispatched",
|
|
111
|
+
"progress",
|
|
112
|
+
"completed",
|
|
113
|
+
"failed",
|
|
114
|
+
"timeout",
|
|
115
|
+
]);
|
|
116
|
+
export const McpCommandStatus = z.object({
|
|
117
|
+
commandId: z.string(),
|
|
118
|
+
error: McpToolError.optional(),
|
|
119
|
+
mcpSessionId: McpSessionId,
|
|
120
|
+
progress: McpToolProgress.optional(),
|
|
121
|
+
status: McpCommandStatusType,
|
|
122
|
+
timestamp: z.number().int(),
|
|
123
|
+
toolName: z.string(),
|
|
124
|
+
});
|
|
125
|
+
export const McpCommandHistoryEntry = z.object({
|
|
126
|
+
commandId: z.string(),
|
|
127
|
+
completedAt: z.number().int().optional(),
|
|
128
|
+
createdAt: z.number().int(),
|
|
129
|
+
error: McpToolError.optional(),
|
|
130
|
+
mcpSessionId: McpSessionId,
|
|
131
|
+
progress: McpToolProgress.optional(),
|
|
132
|
+
result: z.unknown().optional(),
|
|
133
|
+
status: McpCommandStatusType,
|
|
134
|
+
toolCall: McpToolCall.optional(),
|
|
135
|
+
toolName: z.string(),
|
|
136
|
+
updatedAt: z.number().int(),
|
|
137
|
+
});
|
|
@@ -2,3 +2,4 @@ import { Silo } from "../models/silo.js";
|
|
|
2
2
|
export declare const getNativeObjectApiEndpoint: (tenantId: string, silo: Silo) => string;
|
|
3
3
|
export declare const getRegistryApiEndpoint: (tenantId: string, silo: Silo) => string;
|
|
4
4
|
export declare const getAuthApiEndpoint: (tenantId: string, silo: Silo) => string;
|
|
5
|
+
export declare const getSolutionAiApiEndpoint: (tenantId: string, silo: Silo) => string;
|
package/dist/utils/endpoints.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export const getNativeObjectApiEndpoint = (tenantId, silo) => `https://native-object.${tenantId}.my${silo === "prod" ? "" : `.${silo}`}.contextual.io`;
|
|
2
2
|
export const getRegistryApiEndpoint = (tenantId, silo) => `https://native-object-registry.${tenantId}.my${silo === "prod" ? "" : `.${silo}`}.contextual.io`;
|
|
3
3
|
export const getAuthApiEndpoint = (tenantId, silo) => `https://auth.${tenantId}.my${silo === "prod" ? "" : `.${silo}`}.contextual.io`;
|
|
4
|
+
export const getSolutionAiApiEndpoint = (tenantId, silo) => `https://solution-ai.${tenantId}.my${silo === "prod" ? "" : `.${silo}`}.contextual.io`;
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,120 @@
|
|
|
1
1
|
{
|
|
2
2
|
"commands": {
|
|
3
|
+
"mcp": {
|
|
4
|
+
"aliases": [],
|
|
5
|
+
"args": {},
|
|
6
|
+
"description": "Manage local MCP server commands. Start with 'ctxl mcp serve' to run the local MCP bridge.",
|
|
7
|
+
"examples": [
|
|
8
|
+
"<%= config.bin %> <%= command.id %> serve",
|
|
9
|
+
"<%= config.bin %> <%= command.id %> serve flow-editor --flow my-flow-id"
|
|
10
|
+
],
|
|
11
|
+
"flags": {
|
|
12
|
+
"debug": {
|
|
13
|
+
"hidden": true,
|
|
14
|
+
"name": "debug",
|
|
15
|
+
"allowNo": false,
|
|
16
|
+
"type": "boolean"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"hasDynamicHelp": false,
|
|
20
|
+
"hiddenAliases": [],
|
|
21
|
+
"id": "mcp",
|
|
22
|
+
"pluginAlias": "@contextual-io/cli",
|
|
23
|
+
"pluginName": "@contextual-io/cli",
|
|
24
|
+
"pluginType": "core",
|
|
25
|
+
"strict": true,
|
|
26
|
+
"usage": [
|
|
27
|
+
"<%= command.id %> <COMMAND>"
|
|
28
|
+
],
|
|
29
|
+
"enableJsonFlag": false,
|
|
30
|
+
"isESM": true,
|
|
31
|
+
"relativePath": [
|
|
32
|
+
"dist",
|
|
33
|
+
"commands",
|
|
34
|
+
"mcp",
|
|
35
|
+
"index.js"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"mcp:serve": {
|
|
39
|
+
"aliases": [],
|
|
40
|
+
"args": {
|
|
41
|
+
"interface": {
|
|
42
|
+
"default": "flow-editor",
|
|
43
|
+
"description": "Interface type to scope tools for. Available interfaces depend on your platform version.",
|
|
44
|
+
"name": "interface",
|
|
45
|
+
"required": false
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"description": "Start a local MCP HTTP server that connects to SolutionAI for a given interface type. By default it binds to http://localhost:5051/. The server fetches the full tool manifest from SolutionAI and serves all tools immediately. Pass a flowId with each tool call to target a specific flow, or use list_sessions to discover available flows.",
|
|
49
|
+
"examples": [
|
|
50
|
+
"<%= config.bin %> <%= command.id %>",
|
|
51
|
+
"<%= config.bin %> <%= command.id %> flow-editor --flow my-flow-id"
|
|
52
|
+
],
|
|
53
|
+
"flags": {
|
|
54
|
+
"config-id": {
|
|
55
|
+
"char": "C",
|
|
56
|
+
"helpGroup": "GLOBAL",
|
|
57
|
+
"name": "config-id",
|
|
58
|
+
"summary": "Specify config id to use for call.",
|
|
59
|
+
"hasDynamicHelp": false,
|
|
60
|
+
"multiple": false,
|
|
61
|
+
"type": "option"
|
|
62
|
+
},
|
|
63
|
+
"flow": {
|
|
64
|
+
"char": "f",
|
|
65
|
+
"description": "pre-filter session listing to a specific flow ID",
|
|
66
|
+
"name": "flow",
|
|
67
|
+
"hasDynamicHelp": false,
|
|
68
|
+
"multiple": false,
|
|
69
|
+
"type": "option"
|
|
70
|
+
},
|
|
71
|
+
"port": {
|
|
72
|
+
"char": "p",
|
|
73
|
+
"description": "local HTTP port (default: 5051)",
|
|
74
|
+
"name": "port",
|
|
75
|
+
"hasDynamicHelp": false,
|
|
76
|
+
"multiple": false,
|
|
77
|
+
"type": "option"
|
|
78
|
+
},
|
|
79
|
+
"tool-prefix": {
|
|
80
|
+
"char": "t",
|
|
81
|
+
"description": "prefix all MCP tool names with ctxl_",
|
|
82
|
+
"name": "tool-prefix",
|
|
83
|
+
"allowNo": true,
|
|
84
|
+
"type": "boolean"
|
|
85
|
+
},
|
|
86
|
+
"url": {
|
|
87
|
+
"description": "override MCP route URL (http/https)",
|
|
88
|
+
"hidden": true,
|
|
89
|
+
"name": "url",
|
|
90
|
+
"hasDynamicHelp": false,
|
|
91
|
+
"multiple": false,
|
|
92
|
+
"type": "option"
|
|
93
|
+
},
|
|
94
|
+
"verbose": {
|
|
95
|
+
"char": "V",
|
|
96
|
+
"description": "emit verbose MCP runtime diagnostics",
|
|
97
|
+
"name": "verbose",
|
|
98
|
+
"allowNo": false,
|
|
99
|
+
"type": "boolean"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"hasDynamicHelp": false,
|
|
103
|
+
"hiddenAliases": [],
|
|
104
|
+
"id": "mcp:serve",
|
|
105
|
+
"pluginAlias": "@contextual-io/cli",
|
|
106
|
+
"pluginName": "@contextual-io/cli",
|
|
107
|
+
"pluginType": "core",
|
|
108
|
+
"strict": true,
|
|
109
|
+
"enableJsonFlag": false,
|
|
110
|
+
"isESM": true,
|
|
111
|
+
"relativePath": [
|
|
112
|
+
"dist",
|
|
113
|
+
"commands",
|
|
114
|
+
"mcp",
|
|
115
|
+
"serve.js"
|
|
116
|
+
]
|
|
117
|
+
},
|
|
3
118
|
"config:add": {
|
|
4
119
|
"aliases": [],
|
|
5
120
|
"args": {
|
|
@@ -1259,5 +1374,5 @@
|
|
|
1259
1374
|
]
|
|
1260
1375
|
}
|
|
1261
1376
|
},
|
|
1262
|
-
"version": "0.
|
|
1377
|
+
"version": "0.8.1"
|
|
1263
1378
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contextual-io/cli",
|
|
3
3
|
"description": "Contextual CLI",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"author": "Nasser Oloumi",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ctxl": "./bin/run.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
+
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
10
11
|
"@oclif/core": "^4",
|
|
11
12
|
"@oclif/plugin-autocomplete": "^3.2.39",
|
|
12
13
|
"@oclif/plugin-help": "^6",
|
|
@@ -14,7 +15,9 @@
|
|
|
14
15
|
"@oclif/table": "^0.5.2",
|
|
15
16
|
"chalk": "^5.6.2",
|
|
16
17
|
"cross-fetch": "^4.1.0",
|
|
18
|
+
"express": "^5.2.1",
|
|
17
19
|
"open": "^11.0.0",
|
|
20
|
+
"socket.io-client": "^4.8.3",
|
|
18
21
|
"stream-json": "^1.9.1",
|
|
19
22
|
"zod": "4.1.12"
|
|
20
23
|
},
|
|
@@ -24,6 +27,7 @@
|
|
|
24
27
|
"@oclif/test": "^4",
|
|
25
28
|
"@stylistic/eslint-plugin": "^5.6.1",
|
|
26
29
|
"@types/chai": "^4",
|
|
30
|
+
"@types/express": "^5.0.5",
|
|
27
31
|
"@types/mocha": "^10",
|
|
28
32
|
"@types/node": "^18",
|
|
29
33
|
"@types/stream-json": "^1.7.8",
|