MCPcopy Index your code
hub / github.com/callstack/agent-device / handleRequest

Function handleRequest

src/mcp/router.ts:35–57  ·  view source on GitHub ↗
(method: string, params: unknown)

Source from the content-addressed store, hash-verified

33}
34
35async function handleRequest(method: string, params: unknown): Promise<unknown> {
36 switch (method) {
37 case 'initialize':
38 return {
39 protocolVersion: supportedProtocolVersion(params),
40 capabilities: {
41 tools: {},
42 },
43 serverInfo: {
44 name: MCP_SERVER_NAME,
45 version: readVersion(),
46 },
47 };
48 case 'ping':
49 return {};
50 case 'tools/list':
51 return { tools: listCommandTools() };
52 case 'tools/call':
53 return await callTool(params);
54 default:
55 throw new JsonRpcMethodNotFoundError(`Unsupported MCP method: ${method}`);
56 }
57}
58
59async function callTool(params: unknown): Promise<ToolResult> {
60 const record = asRecord(params);

Callers 3

handleMcpMessageFunction · 0.70
transportFunction · 0.50

Calls 4

readVersionFunction · 0.90
listCommandToolsFunction · 0.90
supportedProtocolVersionFunction · 0.85
callToolFunction · 0.85

Tested by

no test coverage detected