MCPcopy
hub / github.com/Doorman11991/smallcode / handleMCPRequest

Function handleMCPRequest

bin/smallcode.js:2858–2882  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

2856}
2857
2858async function handleMCPRequest(request) {
2859 const { id, method } = request;
2860 switch (method) {
2861 case 'initialize':
2862 return { jsonrpc: '2.0', id, result: {
2863 protocolVersion: '2024-11-05',
2864 capabilities: { tools: {} },
2865 serverInfo: { name: 'smallcode', version: VERSION },
2866 }};
2867 case 'tools/list':
2868 return { jsonrpc: '2.0', id, result: { tools: [
2869 { name: 'smallcode_read_file', description: 'Read file contents', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'File path' } }, required: ['path'] } },
2870 { name: 'smallcode_search', description: 'Search code with regex', inputSchema: { type: 'object', properties: { pattern: { type: 'string' }, path: { type: 'string' } }, required: ['pattern'] } },
2871 { name: 'smallcode_patch', description: 'Edit file via search-and-replace', inputSchema: { type: 'object', properties: { path: { type: 'string' }, old_str: { type: 'string' }, new_str: { type: 'string' } }, required: ['path', 'old_str', 'new_str'] } },
2872 { name: 'smallcode_bash', description: 'Run shell command', inputSchema: { type: 'object', properties: { command: { type: 'string' } }, required: ['command'] } },
2873 { name: 'smallcode_memory_load', description: 'Load relevant project memory for a task', inputSchema: { type: 'object', properties: { task: { type: 'string' } }, required: ['task'] } },
2874 { name: 'smallcode_memory_remember', description: 'Save knowledge to project memory', inputSchema: { type: 'object', properties: { type: { type: 'string' }, title: { type: 'string' }, content: { type: 'string' } }, required: ['type', 'title', 'content'] } },
2875 { name: 'smallcode_agent', description: 'Send a prompt to SmallCode agent', inputSchema: { type: 'object', properties: { message: { type: 'string' } }, required: ['message'] } },
2876 ]}};
2877 case 'tools/call':
2878 return await handleMCPToolCall(id, request.params);
2879 default:
2880 return { jsonrpc: '2.0', id, error: { code: -32601, message: `Unknown method: ${method}` }};
2881 }
2882}
2883
2884async function handleMCPToolCall(id, params) {
2885 const { name, arguments: args } = params;

Callers 1

runMCPFunction · 0.85

Calls 1

handleMCPToolCallFunction · 0.85

Tested by

no test coverage detected