test(mcp): replace module mocks with real servers (#35450)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { Server } from "@modelcontextprotocol/sdk/server/index.js"
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
||||
import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js"
|
||||
|
||||
if (process.argv.includes("--hang")) {
|
||||
const pidFile = process.env.MCP_LIFECYCLE_PID_FILE
|
||||
if (!pidFile) throw new Error("MCP_LIFECYCLE_PID_FILE is required")
|
||||
await Bun.write(pidFile, String(process.pid))
|
||||
await new Promise(() => {})
|
||||
}
|
||||
|
||||
const server = new Server({ name: "mcp-lifecycle-stdio", version: "1.0.0" }, { capabilities: { tools: {} } })
|
||||
|
||||
server.setRequestHandler(ListToolsRequestSchema, () =>
|
||||
Promise.resolve({
|
||||
tools: [
|
||||
{
|
||||
name: "current_directory",
|
||||
description: process.cwd(),
|
||||
inputSchema: { type: "object", properties: {} },
|
||||
},
|
||||
],
|
||||
}),
|
||||
)
|
||||
|
||||
await server.connect(new StdioServerTransport())
|
||||
Reference in New Issue
Block a user