Loading...
async function onToolCall(call: ToolCall) {
return server.callTool(call.name, call.args);
}async function onToolCall(call: ToolCall) {
const tool = tools.get(call.name);
if (!tool?.annotations?.readOnlyHint && !(await askUser(call))) {
return { isError: true, content: [{ type: 'text', text: 'User declined' }] };
}
return withTimeout(server.callTool(call.name, call.args), 30_000);
}The client asks before tools that may change data and adds a timeout, instead of running every call blindly.
The host is the AI application the user works in. It creates one MCP client per server connection, and each client talks to exactly one server.
Each client keeps one connection to one server. A host app that uses several servers runs several clients side by side.
Only from trusted servers. Annotations like 'readOnlyHint' are hints from the server, not guarantees, so do not rely on them for security.