@smithery/cli 1.2.3 → 1.2.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/dist/index.js +10 -84
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11868,18 +11868,13 @@ async function startMcpServer() {
|
|
|
11868
11868
|
process.exit(1);
|
|
11869
11869
|
}
|
|
11870
11870
|
let mcpServer;
|
|
11871
|
-
if (entry.
|
|
11871
|
+
if (entry.default && typeof entry.default === "function") {
|
|
11872
11872
|
const sessionId = \`stdio-\${Date.now()}-\${Math.random().toString(36).substring(2)}\`;
|
|
11873
|
-
console.error(
|
|
11874
|
-
|
|
11875
|
-
);
|
|
11876
|
-
mcpServer = entry.createStatefulServer({ sessionId, config });
|
|
11877
|
-
} else if (entry.createStatelessServer && typeof entry.createStatelessServer === "function") {
|
|
11878
|
-
console.error(\`[smithery] Creating stateless server\`);
|
|
11879
|
-
mcpServer = entry.createStatelessServer({ config });
|
|
11873
|
+
console.error(\`[smithery] Creating server.\`);
|
|
11874
|
+
mcpServer = entry.default({ sessionId, config });
|
|
11880
11875
|
} else {
|
|
11881
11876
|
throw new Error(
|
|
11882
|
-
"No valid server export found. Please export
|
|
11877
|
+
"No valid server export found. Please export:\\n- export default function({ sessionId, config }) { ... }"
|
|
11883
11878
|
);
|
|
11884
11879
|
}
|
|
11885
11880
|
const transport = new StdioServerTransport();
|
|
@@ -79965,72 +79960,9 @@ function createStatefulServer(createMcpServer, options) {
|
|
|
79965
79960
|
return { app };
|
|
79966
79961
|
}
|
|
79967
79962
|
|
|
79968
|
-
// node_modules/@smithery/sdk/dist/server/stateless.js
|
|
79969
|
-
var import_express2 = __toESM(require_express2(), 1);
|
|
79970
|
-
function createStatelessServer(createMcpServer, options) {
|
|
79971
|
-
const app = options?.app ?? (0, import_express2.default)();
|
|
79972
|
-
app.use("/mcp", import_express2.default.json());
|
|
79973
|
-
app.post("/mcp", async (req, res) => {
|
|
79974
|
-
try {
|
|
79975
|
-
const configResult = parseAndValidateConfig(req, options?.schema);
|
|
79976
|
-
if (!configResult.ok) {
|
|
79977
|
-
const status = configResult.error.status;
|
|
79978
|
-
res.status(status).json(configResult.error);
|
|
79979
|
-
return;
|
|
79980
|
-
}
|
|
79981
|
-
const config = configResult.value;
|
|
79982
|
-
const server = createMcpServer({ config });
|
|
79983
|
-
const transport = new StreamableHTTPServerTransport({
|
|
79984
|
-
sessionIdGenerator: void 0
|
|
79985
|
-
});
|
|
79986
|
-
res.on("close", () => {
|
|
79987
|
-
transport.close();
|
|
79988
|
-
server.close();
|
|
79989
|
-
});
|
|
79990
|
-
await server.connect(transport);
|
|
79991
|
-
await transport.handleRequest(req, res, req.body);
|
|
79992
|
-
} catch (error) {
|
|
79993
|
-
console.error("Error handling MCP request:", error);
|
|
79994
|
-
if (!res.headersSent) {
|
|
79995
|
-
res.status(500).json({
|
|
79996
|
-
jsonrpc: "2.0",
|
|
79997
|
-
error: {
|
|
79998
|
-
code: -32603,
|
|
79999
|
-
message: "Internal server error"
|
|
80000
|
-
},
|
|
80001
|
-
id: null
|
|
80002
|
-
});
|
|
80003
|
-
}
|
|
80004
|
-
}
|
|
80005
|
-
});
|
|
80006
|
-
app.get("/mcp", async (req, res) => {
|
|
80007
|
-
console.log("Received GET MCP request");
|
|
80008
|
-
res.writeHead(405).end(JSON.stringify({
|
|
80009
|
-
jsonrpc: "2.0",
|
|
80010
|
-
error: {
|
|
80011
|
-
code: -32e3,
|
|
80012
|
-
message: "Method not allowed in stateless mode"
|
|
80013
|
-
},
|
|
80014
|
-
id: null
|
|
80015
|
-
}));
|
|
80016
|
-
});
|
|
80017
|
-
app.delete("/mcp", async (req, res) => {
|
|
80018
|
-
console.log("Received DELETE MCP request");
|
|
80019
|
-
res.writeHead(405).end(JSON.stringify({
|
|
80020
|
-
jsonrpc: "2.0",
|
|
80021
|
-
error: {
|
|
80022
|
-
code: -32e3,
|
|
80023
|
-
message: "Method not allowed in stateless mode"
|
|
80024
|
-
},
|
|
80025
|
-
id: null
|
|
80026
|
-
}));
|
|
80027
|
-
});
|
|
80028
|
-
return { app };
|
|
80029
|
-
}
|
|
80030
|
-
|
|
80031
79963
|
// src/runtime/shttp-bootstrap.ts
|
|
80032
79964
|
var import_cors = __toESM(require_lib4());
|
|
80033
|
-
var
|
|
79965
|
+
var import_express2 = __toESM(require_express2());
|
|
80034
79966
|
var _entry = __toESM(require("virtual:user-module"));
|
|
80035
79967
|
var entry = _entry;
|
|
80036
79968
|
async function startMcpServer() {
|
|
@@ -80038,7 +79970,7 @@ async function startMcpServer() {
|
|
|
80038
79970
|
const port = process.env.PORT || "8181";
|
|
80039
79971
|
console.log(\`[smithery] Starting MCP server on port \${port}\`);
|
|
80040
79972
|
let server;
|
|
80041
|
-
const app = (0,
|
|
79973
|
+
const app = (0, import_express2.default)();
|
|
80042
79974
|
if (process.env.NODE_ENV !== "production") {
|
|
80043
79975
|
console.log(\`[smithery] Injecting cors middleware\`);
|
|
80044
79976
|
app.use(
|
|
@@ -80047,21 +79979,15 @@ async function startMcpServer() {
|
|
|
80047
79979
|
})
|
|
80048
79980
|
);
|
|
80049
79981
|
}
|
|
80050
|
-
if (entry.
|
|
80051
|
-
console.log(\`[smithery] Setting up
|
|
80052
|
-
server = createStatefulServer(entry.
|
|
80053
|
-
schema: entry.configSchema,
|
|
80054
|
-
app
|
|
80055
|
-
});
|
|
80056
|
-
} else if (entry.createStatelessServer && typeof entry.createStatelessServer === "function") {
|
|
80057
|
-
console.log(\`[smithery] Setting up stateless server\`);
|
|
80058
|
-
server = createStatelessServer(entry.createStatelessServer, {
|
|
79982
|
+
if (entry.default && typeof entry.default === "function") {
|
|
79983
|
+
console.log(\`[smithery] Setting up server.\`);
|
|
79984
|
+
server = createStatefulServer(entry.default, {
|
|
80059
79985
|
schema: entry.configSchema,
|
|
80060
79986
|
app
|
|
80061
79987
|
});
|
|
80062
79988
|
} else {
|
|
80063
79989
|
throw new Error(
|
|
80064
|
-
"No valid server export found. Please export
|
|
79990
|
+
"No valid server export found. Please export:\\n- export default function({ sessionId, config }) { ... }"
|
|
80065
79991
|
);
|
|
80066
79992
|
}
|
|
80067
79993
|
server.app.listen(Number.parseInt(port));
|