server.tool('search_docs', { query: z.string() }, async ({ query }) => {
console.log('searching', query);
return { content: [{ type: 'text', text: await search(query) }] };
});server.tool('search_docs', { query: z.string().min(1).max(200) }, async ({ query }) => {
console.error('searching', query);
return { content: [{ type: 'text', text: await search(query) }] };
});A stdio server must log to stderr, because stdout carries protocol messages, and inputs get real limits.
Local stdio servers suit tools that need the user's files or machine. Remote HTTP servers suit shared services and need authentication.
Use an MCP inspector tool or a test client to list tools and call them with sample inputs, and write unit tests for the tool handlers.
Keep it focused. Too many similar tools confuse the model and fill the context, so group related actions and give each tool a clear description.