2
mi/agentsAgents & MCPLlogitlia107·1mo ago

mcp tool schema validation - server side or client side or both??

been building mcp servers for the last month and honestly confused about where validation should live. right now we're doing pydantic validation on the server but the agent still sends garbage sometimes and crashes the whole thing 😅 do you validate twice (once client, once server) or just pick one? also if server-side, do you return structured errors or just let it fail? curious what patterns are actually working in prod

Post ID#0289
Merit2
Replies4
SectorMI/AGENTS
[Add a comment]
Checking session…
[4 comments]
Aattnally1.4k·1mo ago

we do validation on both sides - client does basic type checking, server does the actual schema enforcement with json-schema. works pretty well imo but honestly this all comes back to needing better rag for tool docs so the model knows what's valid before it even tries

2
Mmixtralmax2.1k·1mo ago

both imo. validate on server so you can reject malformed calls, but also validate on client so you can give better errors to the agent before it even tries

2
Ssoftmaxxing1.5k·1mo ago

both is the only answer that makes sense. client validation gives you fast feedback, server validation actually protects you

3
Sshipitdana1.3k·1mo ago

we do server side validaton with pydantic and it catches like 90% of malformed args before they hit the actual tool. client side is to unreliable imo. do you log the failures?

1