apcore-mcp 0.3.0 → 0.5.0
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/dist/adapters/annotations.d.ts +6 -2
- package/dist/adapters/annotations.d.ts.map +1 -1
- package/dist/adapters/annotations.js +27 -9
- package/dist/adapters/annotations.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +20 -5
- package/dist/cli.js.map +1 -1
- package/dist/explorer/handler.d.ts +55 -0
- package/dist/explorer/handler.d.ts.map +1 -0
- package/dist/explorer/handler.js +175 -0
- package/dist/explorer/handler.js.map +1 -0
- package/dist/explorer/html.d.ts +9 -0
- package/dist/explorer/html.d.ts.map +1 -0
- package/dist/explorer/html.js +238 -0
- package/dist/explorer/html.js.map +1 -0
- package/dist/explorer/index.d.ts +6 -0
- package/dist/explorer/index.d.ts.map +1 -0
- package/dist/explorer/index.js +5 -0
- package/dist/explorer/index.js.map +1 -0
- package/dist/index.d.ts +41 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +102 -18
- package/dist/index.js.map +1 -1
- package/dist/server/factory.d.ts +12 -0
- package/dist/server/factory.d.ts.map +1 -1
- package/dist/server/factory.js +73 -9
- package/dist/server/factory.js.map +1 -1
- package/dist/server/router.d.ts +7 -1
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/router.js +65 -5
- package/dist/server/router.js.map +1 -1
- package/dist/server/transport.d.ts +55 -1
- package/dist/server/transport.d.ts.map +1 -1
- package/dist/server/transport.js +114 -1
- package/dist/server/transport.js.map +1 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +19 -2
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-contained HTML page for the MCP Tool Explorer.
|
|
3
|
+
*
|
|
4
|
+
* Single-page application with no external dependencies.
|
|
5
|
+
* Displays registered MCP tools, their schemas, annotations,
|
|
6
|
+
* and optionally allows executing tools from the browser.
|
|
7
|
+
*/
|
|
8
|
+
export const EXPLORER_HTML = `\
|
|
9
|
+
<!DOCTYPE html>
|
|
10
|
+
<html lang="en">
|
|
11
|
+
<head>
|
|
12
|
+
<meta charset="utf-8">
|
|
13
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
14
|
+
<title>MCP Tool Explorer</title>
|
|
15
|
+
<style>
|
|
16
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
17
|
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
|
|
18
|
+
background: #f5f5f5; color: #333; padding: 24px; }
|
|
19
|
+
h1 { font-size: 1.4rem; margin-bottom: 16px; }
|
|
20
|
+
.tool-list { list-style: none; }
|
|
21
|
+
.tool-item { background: #fff; border: 1px solid #ddd; border-radius: 6px;
|
|
22
|
+
padding: 12px 16px; margin-bottom: 8px; cursor: pointer; }
|
|
23
|
+
.tool-item:hover { border-color: #888; }
|
|
24
|
+
.tool-name { font-weight: 600; }
|
|
25
|
+
.tool-desc { color: #666; font-size: 0.9rem; margin-top: 4px; }
|
|
26
|
+
.hint { display: inline-block; background: #e8e8e8; padding: 2px 8px;
|
|
27
|
+
border-radius: 3px; font-size: 0.75rem; margin-right: 4px; }
|
|
28
|
+
.hint-readonly { background: #d4edda; color: #155724; }
|
|
29
|
+
.hint-destructive { background: #f8d7da; color: #721c24; }
|
|
30
|
+
.hint-idempotent { background: #cce5ff; color: #004085; }
|
|
31
|
+
.detail { background: #fff; border: 1px solid #ddd; border-radius: 6px;
|
|
32
|
+
padding: 16px; margin-top: 16px; display: none; }
|
|
33
|
+
.detail.active { display: block; }
|
|
34
|
+
.detail h2 { font-size: 1.1rem; margin-bottom: 12px; }
|
|
35
|
+
.schema-label { font-weight: 600; margin-top: 12px; display: block; }
|
|
36
|
+
pre { background: #282c34; color: #abb2bf; padding: 12px; border-radius: 4px;
|
|
37
|
+
overflow-x: auto; font-size: 0.85rem; margin-top: 4px; }
|
|
38
|
+
#loading { color: #888; }
|
|
39
|
+
.try-it { margin-top: 16px; border-top: 1px solid #eee; padding-top: 16px; }
|
|
40
|
+
.try-it h3 { font-size: 0.95rem; margin-bottom: 8px; }
|
|
41
|
+
.input-editor { width: 100%; min-height: 120px; font-family: monospace;
|
|
42
|
+
font-size: 0.85rem; padding: 10px; border: 1px solid #ddd;
|
|
43
|
+
border-radius: 4px; resize: vertical; background: #fafafa; }
|
|
44
|
+
.execute-btn { margin-top: 8px; padding: 8px 20px; background: #4CAF50; color: #fff;
|
|
45
|
+
border: none; border-radius: 4px; cursor: pointer; font-size: 0.9rem;
|
|
46
|
+
font-weight: 600; }
|
|
47
|
+
.execute-btn:hover { background: #45a049; }
|
|
48
|
+
.execute-btn:disabled { background: #ccc; cursor: not-allowed; }
|
|
49
|
+
.result-area { margin-top: 12px; }
|
|
50
|
+
.result-area pre { background: #1a2332; }
|
|
51
|
+
.result-error { color: #f93e3e; }
|
|
52
|
+
.result-success { color: #49cc90; }
|
|
53
|
+
.exec-disabled { color: #888; font-size: 0.85rem; font-style: italic; margin-top: 16px; }
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
<body>
|
|
57
|
+
<h1>MCP Tool Explorer</h1>
|
|
58
|
+
<div id="loading">Loading tools...</div>
|
|
59
|
+
<ul class="tool-list" id="tools"></ul>
|
|
60
|
+
<div class="detail" id="detail"></div>
|
|
61
|
+
<script>
|
|
62
|
+
(function() {
|
|
63
|
+
var base = window.location.pathname.replace(/\\/$/, '');
|
|
64
|
+
var toolsEl = document.getElementById('tools');
|
|
65
|
+
var detailEl = document.getElementById('detail');
|
|
66
|
+
var loadingEl = document.getElementById('loading');
|
|
67
|
+
var executeEnabled = null;
|
|
68
|
+
|
|
69
|
+
function esc(s) {
|
|
70
|
+
var d = document.createElement('div');
|
|
71
|
+
d.appendChild(document.createTextNode(s));
|
|
72
|
+
return d.innerHTML;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function defaultFromSchema(schema) {
|
|
76
|
+
if (!schema || !schema.properties) return {};
|
|
77
|
+
var result = {};
|
|
78
|
+
var props = schema.properties;
|
|
79
|
+
for (var key in props) {
|
|
80
|
+
if (!props.hasOwnProperty(key)) continue;
|
|
81
|
+
var t = props[key].type;
|
|
82
|
+
if (props[key]['default'] !== undefined) {
|
|
83
|
+
result[key] = props[key]['default'];
|
|
84
|
+
} else if (t === 'string') {
|
|
85
|
+
result[key] = '';
|
|
86
|
+
} else if (t === 'number' || t === 'integer') {
|
|
87
|
+
result[key] = 0;
|
|
88
|
+
} else if (t === 'boolean') {
|
|
89
|
+
result[key] = false;
|
|
90
|
+
} else if (t === 'array') {
|
|
91
|
+
result[key] = [];
|
|
92
|
+
} else if (t === 'object') {
|
|
93
|
+
result[key] = {};
|
|
94
|
+
} else {
|
|
95
|
+
result[key] = null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function hintsHtml(annotations) {
|
|
102
|
+
if (!annotations) return '';
|
|
103
|
+
var parts = [];
|
|
104
|
+
if (annotations.readOnlyHint) parts.push('<span class="hint hint-readonly">readOnly</span>');
|
|
105
|
+
if (annotations.destructiveHint) parts.push('<span class="hint hint-destructive">destructive</span>');
|
|
106
|
+
if (annotations.idempotentHint) parts.push('<span class="hint hint-idempotent">idempotent</span>');
|
|
107
|
+
if (annotations.openWorldHint === false) parts.push('<span class="hint">closedWorld</span>');
|
|
108
|
+
return parts.join('');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
fetch(base + '/tools')
|
|
112
|
+
.then(function(r) { return r.json(); })
|
|
113
|
+
.then(function(tools) {
|
|
114
|
+
loadingEl.style.display = 'none';
|
|
115
|
+
tools.forEach(function(t) {
|
|
116
|
+
var li = document.createElement('li');
|
|
117
|
+
li.className = 'tool-item';
|
|
118
|
+
li.innerHTML =
|
|
119
|
+
'<span class="tool-name">' + esc(t.name) + '</span> ' +
|
|
120
|
+
hintsHtml(t.annotations) +
|
|
121
|
+
'<div class="tool-desc">' + esc(t.description || '') + '</div>';
|
|
122
|
+
li.onclick = function() { loadDetail(t.name); };
|
|
123
|
+
toolsEl.appendChild(li);
|
|
124
|
+
});
|
|
125
|
+
fetch(base + '/tools/__probe__/call', {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
headers: {'Content-Type': 'application/json'},
|
|
128
|
+
body: '{}'
|
|
129
|
+
}).then(function(r) {
|
|
130
|
+
executeEnabled = r.status !== 403;
|
|
131
|
+
}).catch(function() {});
|
|
132
|
+
})
|
|
133
|
+
.catch(function(e) { loadingEl.textContent = 'Error: ' + e; });
|
|
134
|
+
|
|
135
|
+
function loadDetail(name) {
|
|
136
|
+
fetch(base + '/tools/' + encodeURIComponent(name))
|
|
137
|
+
.then(function(r) { return r.json(); })
|
|
138
|
+
.then(function(d) {
|
|
139
|
+
detailEl.className = 'detail active';
|
|
140
|
+
var html =
|
|
141
|
+
'<h2>' + esc(d.name) + '</h2>' +
|
|
142
|
+
'<p>' + esc(d.description || '') + '</p>' +
|
|
143
|
+
'<span class="schema-label">Input Schema</span>' +
|
|
144
|
+
'<pre>' + esc(JSON.stringify(d.inputSchema, null, 2)) + '</pre>';
|
|
145
|
+
|
|
146
|
+
if (d.annotations) {
|
|
147
|
+
html += '<span class="schema-label">Annotations</span>' +
|
|
148
|
+
'<pre>' + esc(JSON.stringify(d.annotations, null, 2)) + '</pre>';
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
html += '<div class="try-it" id="try-it-section">' +
|
|
152
|
+
'<h3>Try it</h3>' +
|
|
153
|
+
'<textarea class="input-editor" id="input-editor">' +
|
|
154
|
+
esc(JSON.stringify(defaultFromSchema(d.inputSchema), null, 2)) +
|
|
155
|
+
'</textarea>' +
|
|
156
|
+
'<button class="execute-btn" id="execute-btn">Execute</button>' +
|
|
157
|
+
'<div class="result-area" id="result-area"></div>' +
|
|
158
|
+
'</div>';
|
|
159
|
+
|
|
160
|
+
detailEl.innerHTML = html;
|
|
161
|
+
|
|
162
|
+
document.getElementById('execute-btn').onclick = function() {
|
|
163
|
+
execTool(d.name);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
if (executeEnabled === false) {
|
|
167
|
+
var section = document.getElementById('try-it-section');
|
|
168
|
+
if (section) section.innerHTML =
|
|
169
|
+
'<p class="exec-disabled">' +
|
|
170
|
+
'Tool execution is disabled. ' +
|
|
171
|
+
'Launch with --allow-execute to enable.</p>';
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
.catch(function(e) {
|
|
175
|
+
detailEl.className = 'detail active';
|
|
176
|
+
detailEl.innerHTML = '<p class="result-error">Failed to load tool details: ' + esc(e.message) + '</p>';
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function execTool(name) {
|
|
181
|
+
var btn = document.getElementById('execute-btn');
|
|
182
|
+
var editor = document.getElementById('input-editor');
|
|
183
|
+
var resultArea = document.getElementById('result-area');
|
|
184
|
+
|
|
185
|
+
var inputText = editor.value.trim();
|
|
186
|
+
var inputs;
|
|
187
|
+
try {
|
|
188
|
+
inputs = inputText ? JSON.parse(inputText) : {};
|
|
189
|
+
} catch (e) {
|
|
190
|
+
resultArea.innerHTML = '<p class="result-error">Invalid JSON: ' + esc(e.message) + '</p>';
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
btn.disabled = true;
|
|
195
|
+
btn.textContent = 'Executing...';
|
|
196
|
+
resultArea.innerHTML = '';
|
|
197
|
+
|
|
198
|
+
fetch(base + '/tools/' + encodeURIComponent(name) + '/call', {
|
|
199
|
+
method: 'POST',
|
|
200
|
+
headers: {'Content-Type': 'application/json'},
|
|
201
|
+
body: JSON.stringify(inputs)
|
|
202
|
+
})
|
|
203
|
+
.then(function(r) {
|
|
204
|
+
if (r.status === 403) {
|
|
205
|
+
executeEnabled = false;
|
|
206
|
+
var section = document.getElementById('try-it-section');
|
|
207
|
+
if (section) section.innerHTML =
|
|
208
|
+
'<p class="exec-disabled">' +
|
|
209
|
+
'Tool execution is disabled. ' +
|
|
210
|
+
'Launch with --allow-execute to enable.</p>';
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
return r.json().then(function(data) { return {status: r.status, data: data}; });
|
|
214
|
+
})
|
|
215
|
+
.then(function(result) {
|
|
216
|
+
if (!result) return;
|
|
217
|
+
btn.disabled = false;
|
|
218
|
+
btn.textContent = 'Execute';
|
|
219
|
+
if (result.status >= 400) {
|
|
220
|
+
resultArea.innerHTML = '<span class="schema-label result-error">Error (' + result.status + ')</span>' +
|
|
221
|
+
'<pre>' + esc(JSON.stringify(result.data, null, 2)) + '</pre>';
|
|
222
|
+
} else {
|
|
223
|
+
resultArea.innerHTML = '<span class="schema-label result-success">Result</span>' +
|
|
224
|
+
'<pre>' + esc(JSON.stringify(result.data, null, 2)) + '</pre>';
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
.catch(function(e) {
|
|
228
|
+
btn.disabled = false;
|
|
229
|
+
btn.textContent = 'Execute';
|
|
230
|
+
resultArea.innerHTML = '<p class="result-error">Request failed: ' + esc(e.message) + '</p>';
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
})();
|
|
234
|
+
</script>
|
|
235
|
+
</body>
|
|
236
|
+
</html>
|
|
237
|
+
`;
|
|
238
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/explorer/html.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqO5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/explorer/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/explorer/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* - toOpenaiTools(registryOrExecutor, options?) - Export OpenAI tool definitions
|
|
7
7
|
*/
|
|
8
8
|
import type { ConvertRegistryOptions } from "./converters/openai.js";
|
|
9
|
-
import type {
|
|
9
|
+
import type { MetricsExporter } from "./server/transport.js";
|
|
10
|
+
import type { RegistryOrExecutor, Registry, Executor, OpenAIToolDef } from "./types.js";
|
|
10
11
|
export declare const VERSION: string;
|
|
11
12
|
export type { Registry, Executor, RegistryOrExecutor, OpenAIToolDef } from "./types.js";
|
|
12
13
|
export type { ModuleDescriptor, ModuleAnnotations, JsonSchema, ModuleError, McpAnnotationsDict, McpErrorResponse, TextContentDict, } from "./types.js";
|
|
@@ -17,9 +18,12 @@ export { createBridgeContext } from "./server/context.js";
|
|
|
17
18
|
export type { BridgeContext } from "./server/context.js";
|
|
18
19
|
export { MCPServerFactory } from "./server/factory.js";
|
|
19
20
|
export { ExecutionRouter } from "./server/router.js";
|
|
20
|
-
export type { CallResult, HandleCallExtra } from "./server/router.js";
|
|
21
|
+
export type { CallResult, HandleCallExtra, ExecutionRouterOptions } from "./server/router.js";
|
|
21
22
|
export { RegistryListener } from "./server/listener.js";
|
|
22
23
|
export { TransportManager } from "./server/transport.js";
|
|
24
|
+
export type { MetricsExporter } from "./server/transport.js";
|
|
25
|
+
export { ExplorerHandler } from "./explorer/index.js";
|
|
26
|
+
export type { ExplorerHandlerOptions } from "./explorer/index.js";
|
|
23
27
|
export { AnnotationMapper } from "./adapters/annotations.js";
|
|
24
28
|
export { SchemaConverter } from "./adapters/schema.js";
|
|
25
29
|
export { ErrorMapper } from "./adapters/errors.js";
|
|
@@ -27,6 +31,23 @@ export { ModuleIDNormalizer } from "./adapters/idNormalizer.js";
|
|
|
27
31
|
export { OpenAIConverter } from "./converters/openai.js";
|
|
28
32
|
export type { ConvertOptions, ConvertRegistryOptions } from "./converters/openai.js";
|
|
29
33
|
export type { BuildToolsOptions } from "./server/factory.js";
|
|
34
|
+
/**
|
|
35
|
+
* Extract Registry from either a Registry or Executor instance.
|
|
36
|
+
*
|
|
37
|
+
* If the argument has a `registry` property (i.e. it's an Executor),
|
|
38
|
+
* returns that property. Otherwise assumes it's a Registry and returns it directly.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveRegistry(registryOrExecutor: RegistryOrExecutor): Registry;
|
|
41
|
+
/**
|
|
42
|
+
* Get or create an Executor from either a Registry or Executor instance.
|
|
43
|
+
*
|
|
44
|
+
* If the argument already has `call` or `callAsync`, returns it directly.
|
|
45
|
+
* If a bare Registry is passed, attempts to dynamically import the Executor
|
|
46
|
+
* from apcore-js and create a default instance (matching Python's resolve_executor).
|
|
47
|
+
*
|
|
48
|
+
* @throws {Error} If the argument is a Registry and apcore-js is not installed.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveExecutor(registryOrExecutor: RegistryOrExecutor): Executor;
|
|
30
51
|
/** Options for serve() */
|
|
31
52
|
export interface ServeOptions {
|
|
32
53
|
/** Transport type. Default: "stdio" */
|
|
@@ -43,6 +64,24 @@ export interface ServeOptions {
|
|
|
43
64
|
dynamic?: boolean;
|
|
44
65
|
/** Enable input validation against schemas. Default: false */
|
|
45
66
|
validateInputs?: boolean;
|
|
67
|
+
/** Filter modules by tags. Default: null (no filtering) */
|
|
68
|
+
tags?: string[] | null;
|
|
69
|
+
/** Filter modules by prefix. Default: null (no filtering) */
|
|
70
|
+
prefix?: string | null;
|
|
71
|
+
/** Minimum log level. Suppresses console methods below this level. Default: undefined (no suppression) */
|
|
72
|
+
logLevel?: "DEBUG" | "INFO" | "WARNING" | "ERROR" | "CRITICAL";
|
|
73
|
+
/** Callback invoked before the server starts. */
|
|
74
|
+
onStartup?: () => void | Promise<void>;
|
|
75
|
+
/** Callback invoked after the server stops (or on error). */
|
|
76
|
+
onShutdown?: () => void | Promise<void>;
|
|
77
|
+
/** Optional MetricsCollector for Prometheus /metrics endpoint. */
|
|
78
|
+
metricsCollector?: MetricsExporter;
|
|
79
|
+
/** Enable the browser-based Tool Explorer UI (HTTP transports only). Default: false */
|
|
80
|
+
explorer?: boolean;
|
|
81
|
+
/** URL prefix for the explorer. Default: "/explorer" */
|
|
82
|
+
explorerPrefix?: string;
|
|
83
|
+
/** Allow tool execution from the explorer UI. Default: false */
|
|
84
|
+
allowExecute?: boolean;
|
|
46
85
|
}
|
|
47
86
|
/**
|
|
48
87
|
* Launch an MCP Server that exposes all apcore modules as tools.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIrE,OAAO,KAAK,EACV,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EACV,kBAAkB,EAClB,QAAQ,EACR,QAAQ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B,CAAC,EAAE,eAAe,CAAC;IACnC,uFAAuF;IACvF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAsB,KAAK,CACzB,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CA+Gf;AAED,kCAAkC;AAClC,MAAM,WAAW,oBAAqB,SAAQ,sBAAsB;CAAG;AAEvE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,kBAAkB,EAAE,kBAAkB,EACtC,OAAO,GAAE,oBAAyB,GACjC,aAAa,EAAE,CAKjB"}
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { OpenAIConverter } from "./converters/openai.js";
|
|
|
10
10
|
import { MCPServerFactory } from "./server/factory.js";
|
|
11
11
|
import { ExecutionRouter } from "./server/router.js";
|
|
12
12
|
import { TransportManager } from "./server/transport.js";
|
|
13
|
+
import { ExplorerHandler } from "./explorer/handler.js";
|
|
13
14
|
const require = createRequire(import.meta.url);
|
|
14
15
|
const pkg = require("../package.json");
|
|
15
16
|
export const VERSION = pkg.version;
|
|
@@ -22,6 +23,7 @@ export { MCPServerFactory } from "./server/factory.js";
|
|
|
22
23
|
export { ExecutionRouter } from "./server/router.js";
|
|
23
24
|
export { RegistryListener } from "./server/listener.js";
|
|
24
25
|
export { TransportManager } from "./server/transport.js";
|
|
26
|
+
export { ExplorerHandler } from "./explorer/index.js";
|
|
25
27
|
export { AnnotationMapper } from "./adapters/annotations.js";
|
|
26
28
|
export { SchemaConverter } from "./adapters/schema.js";
|
|
27
29
|
export { ErrorMapper } from "./adapters/errors.js";
|
|
@@ -29,8 +31,11 @@ export { ModuleIDNormalizer } from "./adapters/idNormalizer.js";
|
|
|
29
31
|
export { OpenAIConverter } from "./converters/openai.js";
|
|
30
32
|
/**
|
|
31
33
|
* Extract Registry from either a Registry or Executor instance.
|
|
34
|
+
*
|
|
35
|
+
* If the argument has a `registry` property (i.e. it's an Executor),
|
|
36
|
+
* returns that property. Otherwise assumes it's a Registry and returns it directly.
|
|
32
37
|
*/
|
|
33
|
-
function resolveRegistry(registryOrExecutor) {
|
|
38
|
+
export function resolveRegistry(registryOrExecutor) {
|
|
34
39
|
if ("registry" in registryOrExecutor) {
|
|
35
40
|
// It's an Executor — get its registry
|
|
36
41
|
return registryOrExecutor.registry;
|
|
@@ -40,16 +45,31 @@ function resolveRegistry(registryOrExecutor) {
|
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
47
|
* Get or create an Executor from either a Registry or Executor instance.
|
|
48
|
+
*
|
|
49
|
+
* If the argument already has `call` or `callAsync`, returns it directly.
|
|
50
|
+
* If a bare Registry is passed, attempts to dynamically import the Executor
|
|
51
|
+
* from apcore-js and create a default instance (matching Python's resolve_executor).
|
|
52
|
+
*
|
|
53
|
+
* @throws {Error} If the argument is a Registry and apcore-js is not installed.
|
|
43
54
|
*/
|
|
44
|
-
function resolveExecutor(registryOrExecutor) {
|
|
55
|
+
export function resolveExecutor(registryOrExecutor) {
|
|
45
56
|
if ("call" in registryOrExecutor || "callAsync" in registryOrExecutor) {
|
|
46
57
|
// Already an Executor
|
|
47
58
|
return registryOrExecutor;
|
|
48
59
|
}
|
|
49
|
-
// It's a Registry —
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
// It's a bare Registry — create a default Executor
|
|
61
|
+
try {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
63
|
+
const apcore = require("apcore-js");
|
|
64
|
+
const ExecutorClass = apcore.Executor ?? apcore.default?.Executor;
|
|
65
|
+
if (ExecutorClass) {
|
|
66
|
+
return new ExecutorClass({ registry: registryOrExecutor });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// apcore-js not installed — fall through to error
|
|
71
|
+
}
|
|
72
|
+
throw new Error("serve() requires an Executor instance, or apcore-js must be installed to auto-create one from a Registry.");
|
|
53
73
|
}
|
|
54
74
|
/**
|
|
55
75
|
* Launch an MCP Server that exposes all apcore modules as tools.
|
|
@@ -58,29 +78,93 @@ function resolveExecutor(registryOrExecutor) {
|
|
|
58
78
|
* @param options - Server configuration options.
|
|
59
79
|
*/
|
|
60
80
|
export async function serve(registryOrExecutor, options = {}) {
|
|
61
|
-
const { transport = "stdio", host = "127.0.0.1", port = 8000, name = "apcore-mcp", version = VERSION, } = options;
|
|
81
|
+
const { transport = "stdio", host = "127.0.0.1", port = 8000, name = "apcore-mcp", version = VERSION, validateInputs, tags, prefix, logLevel, onStartup, onShutdown, metricsCollector, explorer = false, explorerPrefix = "/explorer", allowExecute = false, } = options;
|
|
82
|
+
// Input validation (matching Python's checks)
|
|
83
|
+
if (!name || name.length === 0) {
|
|
84
|
+
throw new Error("name must not be empty");
|
|
85
|
+
}
|
|
86
|
+
if (name.length > 255) {
|
|
87
|
+
throw new Error("name must not exceed 255 characters");
|
|
88
|
+
}
|
|
89
|
+
if (tags) {
|
|
90
|
+
for (const tag of tags) {
|
|
91
|
+
if (!tag || tag.length === 0) {
|
|
92
|
+
throw new Error("tags must not contain empty strings");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (prefix !== undefined && prefix !== null && prefix.length === 0) {
|
|
97
|
+
throw new Error("prefix must not be empty if provided");
|
|
98
|
+
}
|
|
99
|
+
if (explorer && !explorerPrefix.startsWith("/")) {
|
|
100
|
+
throw new Error("explorerPrefix must start with '/'");
|
|
101
|
+
}
|
|
102
|
+
// Save original console methods before suppression
|
|
103
|
+
const origDebug = console.debug;
|
|
104
|
+
const origInfo = console.info;
|
|
105
|
+
const origWarn = console.warn;
|
|
106
|
+
const origError = console.error;
|
|
107
|
+
// Apply log-level suppression
|
|
108
|
+
if (logLevel) {
|
|
109
|
+
const levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"];
|
|
110
|
+
const minLevel = levels.indexOf(logLevel);
|
|
111
|
+
if (minLevel > 0)
|
|
112
|
+
console.debug = () => { };
|
|
113
|
+
if (minLevel > 1)
|
|
114
|
+
console.info = () => { };
|
|
115
|
+
if (minLevel > 2)
|
|
116
|
+
console.warn = () => { };
|
|
117
|
+
if (minLevel > 3)
|
|
118
|
+
console.error = () => { };
|
|
119
|
+
}
|
|
62
120
|
const registry = resolveRegistry(registryOrExecutor);
|
|
63
121
|
const executor = resolveExecutor(registryOrExecutor);
|
|
64
122
|
// Build MCP server components
|
|
65
123
|
const factory = new MCPServerFactory();
|
|
66
124
|
const server = factory.createServer(name, version);
|
|
67
|
-
const tools = factory.buildTools(registry);
|
|
68
|
-
const router = new ExecutionRouter(executor);
|
|
125
|
+
const tools = factory.buildTools(registry, { tags, prefix });
|
|
126
|
+
const router = new ExecutionRouter(executor, { validateInputs });
|
|
69
127
|
factory.registerHandlers(server, tools, router);
|
|
70
|
-
|
|
128
|
+
factory.registerResourceHandlers(server, registry);
|
|
129
|
+
origInfo(`Starting MCP server '${name}' v${version} with ${tools.length} tools via ${transport}`);
|
|
130
|
+
// Invoke startup callback
|
|
131
|
+
await onStartup?.();
|
|
71
132
|
// Select and run transport
|
|
72
133
|
const transportManager = new TransportManager();
|
|
73
|
-
|
|
74
|
-
|
|
134
|
+
transportManager.setModuleCount(tools.length);
|
|
135
|
+
if (metricsCollector) {
|
|
136
|
+
transportManager.setMetricsCollector(metricsCollector);
|
|
75
137
|
}
|
|
76
|
-
|
|
77
|
-
|
|
138
|
+
// Mount explorer for HTTP transports only
|
|
139
|
+
const transportLower = transport.toLowerCase();
|
|
140
|
+
if (explorer && (transportLower === "streamable-http" || transportLower === "sse")) {
|
|
141
|
+
const explorerHandler = new ExplorerHandler(tools, router, {
|
|
142
|
+
allowExecute,
|
|
143
|
+
prefix: explorerPrefix,
|
|
144
|
+
});
|
|
145
|
+
transportManager.setExplorerHandler(explorerHandler);
|
|
146
|
+
origInfo(`Tool Explorer enabled at ${explorerPrefix}`);
|
|
78
147
|
}
|
|
79
|
-
|
|
80
|
-
|
|
148
|
+
try {
|
|
149
|
+
if (transport === "stdio") {
|
|
150
|
+
await transportManager.runStdio(server);
|
|
151
|
+
}
|
|
152
|
+
else if (transport === "streamable-http") {
|
|
153
|
+
await transportManager.runStreamableHttp(server, { host, port });
|
|
154
|
+
}
|
|
155
|
+
else if (transport === "sse") {
|
|
156
|
+
await transportManager.runSse(server, { host, port });
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new Error(`Unknown transport: '${transport}'. Expected 'stdio', 'streamable-http', or 'sse'.`);
|
|
160
|
+
}
|
|
81
161
|
}
|
|
82
|
-
|
|
83
|
-
|
|
162
|
+
finally {
|
|
163
|
+
console.debug = origDebug;
|
|
164
|
+
console.info = origInfo;
|
|
165
|
+
console.warn = origWarn;
|
|
166
|
+
console.error = origError;
|
|
167
|
+
await onShutdown?.();
|
|
84
168
|
}
|
|
85
169
|
}
|
|
86
170
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAA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KD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,kBAAsC,EACtC,UAAgC,EAAE;IAElC,MAAM,QAAQ,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;IACrD,MAAM,SAAS,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,MAAM,KAAK,GAAG,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/server/factory.d.ts
CHANGED
|
@@ -44,6 +44,18 @@ export declare class MCPServerFactory {
|
|
|
44
44
|
* Skips modules that return null definitions or throw errors (with console.warn).
|
|
45
45
|
*/
|
|
46
46
|
buildTools(registry: Registry, options?: BuildToolsOptions): Tool[];
|
|
47
|
+
/**
|
|
48
|
+
* Register resources/list and resources/read handlers for modules with documentation.
|
|
49
|
+
*
|
|
50
|
+
* Iterates over registry.list(), gets each definition, and filters for
|
|
51
|
+
* descriptors that have a non-null `documentation` field. Registers:
|
|
52
|
+
* - resources/list: returns Resource objects with URI docs://{module_id}
|
|
53
|
+
* - resources/read: returns documentation text for the requested module
|
|
54
|
+
*
|
|
55
|
+
* @param server - The MCP Server to register handlers on
|
|
56
|
+
* @param registry - Registry to discover modules with documentation
|
|
57
|
+
*/
|
|
58
|
+
registerResourceHandlers(server: Server, registry: Registry): void;
|
|
47
59
|
/**
|
|
48
60
|
* Register tools/list and tools/call request handlers on a Server instance.
|
|
49
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/server/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/server/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAOnE,OAAO,KAAK,EACV,IAAI,EAIL,MAAM,oCAAoC,CAAC;AAI5C,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkB;IACnD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAmB;;IAOrD;;;;;;OAMG;IACH,YAAY,CACV,IAAI,GAAE,MAAqB,EAC3B,OAAO,GAAE,MAAgB,GACxB,MAAM;IAOT;;;;;;;;OAQG;IACH,SAAS,CAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI;IA+C7C;;;;;OAKG;IACH,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,EAAE;IA2BnE;;;;;;;;;;OAUG;IACH,wBAAwB,CACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GACjB,IAAI;IAsDP;;;;;;OAMG;IACH,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,IAAI,EAAE,EACb,MAAM,EAAE,eAAe,GACtB,IAAI;CA0CR"}
|