mcpboot 0.1.2 → 0.1.3
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/index.js +16 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1062,6 +1062,9 @@ import {
|
|
|
1062
1062
|
} from "@modelcontextprotocol/sdk/types.js";
|
|
1063
1063
|
import http from "node:http";
|
|
1064
1064
|
import { randomBytes } from "node:crypto";
|
|
1065
|
+
import { createRequire } from "node:module";
|
|
1066
|
+
var require2 = createRequire(import.meta.url);
|
|
1067
|
+
var { version } = require2("../package.json");
|
|
1065
1068
|
function readBody(req) {
|
|
1066
1069
|
return new Promise((resolve, reject) => {
|
|
1067
1070
|
const chunks = [];
|
|
@@ -1077,7 +1080,7 @@ function readBody(req) {
|
|
|
1077
1080
|
req.on("error", reject);
|
|
1078
1081
|
});
|
|
1079
1082
|
}
|
|
1080
|
-
function createExposedServer(config, executor) {
|
|
1083
|
+
function createExposedServer(config, executor, compiled) {
|
|
1081
1084
|
const httpServer = http.createServer(async (req, res) => {
|
|
1082
1085
|
const reqId = randomBytes(6).toString("hex");
|
|
1083
1086
|
setRequestId(reqId);
|
|
@@ -1100,6 +1103,17 @@ function createExposedServer(config, executor) {
|
|
|
1100
1103
|
});
|
|
1101
1104
|
mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
1102
1105
|
const { name, arguments: args } = request.params;
|
|
1106
|
+
if (name === "_mcp_metadata") {
|
|
1107
|
+
return {
|
|
1108
|
+
content: [{ type: "text", text: JSON.stringify({
|
|
1109
|
+
stage: "boot",
|
|
1110
|
+
version,
|
|
1111
|
+
upstream_url: null,
|
|
1112
|
+
whitelist_domains: compiled.whitelist_domains,
|
|
1113
|
+
tools: Array.from(compiled.tools.values())
|
|
1114
|
+
}) }]
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1103
1117
|
logEvent("mcp_call_tool_start", {
|
|
1104
1118
|
tool_name: name,
|
|
1105
1119
|
args: args ?? {}
|
|
@@ -1285,7 +1299,7 @@ async function main(argv = process.argv) {
|
|
|
1285
1299
|
const whitelistedFetch = createWhitelistedFetch(activeWhitelist);
|
|
1286
1300
|
const sandbox = createSandbox(whitelistedFetch);
|
|
1287
1301
|
const executor = createExecutor(compiled, sandbox);
|
|
1288
|
-
const server = createExposedServer(config.server, executor);
|
|
1302
|
+
const server = createExposedServer(config.server, executor, compiled);
|
|
1289
1303
|
const port = await server.start();
|
|
1290
1304
|
log(`Listening on http://localhost:${port}/mcp`);
|
|
1291
1305
|
log(`Serving ${executor.getExposedTools().length} tool(s)`);
|