{"id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","title":"Explain Model Context Protocol (MCP)","created_at":"2025-11-03T20:28:19Z","saved":true,"shared":true,"branch_id":"0262e960-4d25-432d-8335-4035feaf6525","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"tag_ids":[],"read_only":true}
[{"id":"4a8e9cfd-3b30-47a9-a8d2-4dcff76abaec","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:28:20Z","state":"done","prompt":"https://modelcontextprotocol.io/specification/2025-03-26/basic\n\nExplain mcp to me. What is the client, the host the server. Give some examples","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" >Overview - Model Context Protocol</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 100%, transparent 100%)\">100%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Overview - Model Context Protocol](https://modelcontextprotocol.io/specification/2025-03-26/basic) (100%)\n","reply":"<details><summary>Gathered key details from:<p></p>\n<ul>\n<li><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">Overview - Model Context Protocol</a></li></ul></summary>\n\n<h3>Query</h3>\n<p>Explain MCP, client, host, and server, and provide examples.</p>\n<h3>Response</h3>\n<p>The Model Context Protocol consists of several key components that work together:</p>\n<ul>\n<li>\n<p><strong>Base Protocol</strong>: Core JSON-RPC message types</p>\n</li>\n<li>\n<p><strong>Lifecycle Management</strong>: Connection initialization, capability negotiation, and session control</p>\n</li>\n<li>\n<p><strong>Server Features</strong>: Resources, prompts, and tools exposed by servers</p>\n</li>\n<li>\n<p><strong>Client Features</strong>: Sampling and root directory lists provided by clients</p>\n</li>\n<li>\n<p><strong>Utilities</strong>: Cross-cutting concerns like logging and argument completion</p>\n</li>\n</ul>\n<p>All implementations <strong>MUST</strong> support the base protocol and lifecycle management components. Other components <strong>MAY</strong> be implemented based on the specific needs of the application. These protocol layers establish clear separation of concerns while enabling rich interactions between clients and servers. The modular design allows implementations to support exactly the features they need.</p>\n<hr>\n<p>All messages between MCP clients and servers <strong>MUST</strong> follow the<a href=\"https://www.jsonrpc.org/specification\" target=\"_blank\">JSON-RPC 2.0</a> specification. The protocol defines these types of messages:</p>\n<h3>Requests</h3>\n<p>Requests are sent from the client to the server or vice versa, to initiate an operation.</p>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code>{\n jsonrpc: \"2.0\";\n id: string | number;\n method: string;\n params?: {\n [key: string]: unknown;\n };\n}\n</code></pre></div>\n<ul>\n<li>Requests <strong>MUST</strong> include a string or integer ID.</li>\n<li>Unlike base JSON-RPC, the ID <strong>MUST NOT</strong> be <code>null</code>.</li>\n<li>The request ID <strong>MUST NOT</strong> have been previously used by the requestor within the same session.</li>\n</ul>\n<h3>Responses</h3>\n<p>Responses are sent in reply to requests, containing the result or error of the operation.</p>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code>{\n jsonrpc: \"2.0\";\n id: string | number;\n result?: {\n [key: string]: unknown;\n }\n error?: {\n code: number;\n message: string;\n data?: unknown;\n }\n}\n</code></pre></div>\n<ul>\n<li>Responses <strong>MUST</strong> include the same ID as the request they correspond to.</li>\n<li><strong>Responses</strong> are further sub-categorized as either <strong>successful results</strong> or<strong>errors</strong>. Either a <code>result</code> or an <code>error</code> <strong>MUST</strong> be set. A response <strong>MUST NOT</strong>set both.</li>\n<li>Results <strong>MAY</strong> follow any JSON object structure, while errors <strong>MUST</strong> include an error code and message at minimum.</li>\n<li>Error codes <strong>MUST</strong> be integers.</li>\n</ul>\n<h3>Notifications</h3>\n<p>Notifications are sent from the client to the server or vice versa, as a one-way message. The receiver <strong>MUST NOT</strong> send a response.</p>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code>{\n jsonrpc: \"2.0\";\n method: string;\n params?: {\n [key: string]: unknown;\n };\n}\n</code></pre></div>\n<ul>\n<li>Notifications <strong>MUST NOT</strong> include an ID.</li>\n</ul>\n<hr>\n<ul>\n<li>\n<p><strong>Server Features</strong>: Resources, prompts, and tools exposed by servers</p>\n</li>\n<li>\n<p><strong>Client Features</strong>: Sampling and root directory lists provided by clients</p>\n</li>\n</ul>\n<hr>\n<ul>\n<li><strong>Client Features</strong>: Sampling and root directory lists provided by clients</li>\n</ul>\n</details><h1>Model Context Protocol (MCP)</h1>\n<p>MCP is a JSON-RPC 2.0-based protocol enabling standardized communication between AI applications and data sources/tools. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic#:~:text=The%20Model,they%20need.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Overview - Model Context Protocol</b></a><span class=\"passage\">The Model Context Protocol consists of several key components that work together: * **Base Protocol**: Core JSON-RPC message types * **Lifecycle Management**: Connection initialization, capability negotiation, and session control * **Server Features**: Resources, prompts, and tools exposed by servers * **Client Features**: Sampling and root directory lists provided by clients * **Utilities**: Cross-cutting concerns like logging and argument completion All implementations **MUST** support the ...</span></span></sup></p>\n<h2>Architecture</h2>\n<p><strong>Client</strong>: The AI application (e.g., Claude Desktop, IDE) that consumes capabilities. Provides sampling (LLM access) and root directory lists. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic#:~:text=%2A%20%2A%2AClient,by%20clients\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Overview - Model Context Protocol</b></a><span class=\"passage\">* **Client Features**: Sampling and root directory lists provided by clients</span></span></sup></p>\n<p><strong>Server</strong>: Exposes resources (data), prompts (templates), and tools (functions) that clients can use. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic#:~:text=%2A%20%2A%2AServer,by%20clients\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Overview - Model Context Protocol</b></a><span class=\"passage\">* **Server Features**: Resources, prompts, and tools exposed by servers * **Client Features**: Sampling and root directory lists provided by clients</span></span></sup></p>\n<p><strong>Host</strong>: The runtime environment managing client-server connections (often the client application itself handles this).</p>\n<h2>Communication</h2>\n<p>Uses three message types: <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic#:~:text=All%20messages,an%20ID.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Overview - Model Context Protocol</b></a><span class=\"passage\">All messages between MCP clients and servers **MUST** follow the[JSON-RPC 2.0](https://www.jsonrpc.org/specification) specification. The protocol defines these types of messages: ### Requests Requests are sent from the client to the server or vice versa, to initiate an operation. ``` { jsonrpc: \"2.0\"; id: string | number; method: string; params?: { [key: string]: unknown; }; } ``` * Requests **MUST** include a string or integer ID. * Unlike base JSON-RPC, the ID **MUST NOT** be `null`. * The ...</span></span></sup></p>\n<ul>\n<li><strong>Requests</strong>: Bidirectional, require unique ID and response</li>\n<li><strong>Responses</strong>: Reply with result or error, matching request ID</li>\n<li><strong>Notifications</strong>: One-way messages, no response expected</li>\n</ul>\n<h2>Examples</h2>\n<p><strong>Server exposing a database</strong>:</p>\n<div class=\"codehilite\"><span class=\"filename\">Typescript</span><pre><span></span><code>// Server provides resources (database tables)\n// Client requests data via JSON-RPC\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"resources/read\",\n \"params\": { \"uri\": \"db://users\" }\n}\n</code></pre></div>\n<p><strong>Client requesting LLM sampling</strong>:</p>\n<div class=\"codehilite\"><span class=\"filename\">Typescript</span><pre><span></span><code>// Server asks client to generate text\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 2,\n \"method\": \"sampling/createMessage\",\n \"params\": { \"messages\": [...] }\n}\n</code></pre></div>\n<p><strong>Server exposing tools</strong>:</p>\n<ul>\n<li>File system server: read/write operations</li>\n<li>API server: HTTP request tools</li>\n<li>Calculator server: math functions</li>\n</ul>\n<p>Base protocol and lifecycle management are mandatory; other features are optional. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic#:~:text=The%20Model,they%20need.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Overview - Model Context Protocol</b></a><span class=\"passage\">The Model Context Protocol consists of several key components that work together: * **Base Protocol**: Core JSON-RPC message types * **Lifecycle Management**: Connection initialization, capability negotiation, and session control * **Server Features**: Resources, prompts, and tools exposed by servers * **Client Features**: Sampling and root directory lists provided by clients * **Utilities**: Cross-cutting concerns like logging and argument completion All implementations **MUST** support the ...</span></span></sup></p>","md":"# Model Context Protocol (MCP)\n\nMCP is a JSON-RPC 2.0-based protocol enabling standardized communication between AI applications and data sources/tools. [^1]\n\n## Architecture\n\n**Client**: The AI application (e.g., Claude Desktop, IDE) that consumes capabilities. Provides sampling (LLM access) and root directory lists. [^1]\n\n**Server**: Exposes resources (data), prompts (templates), and tools (functions) that clients can use. [^1]\n\n**Host**: The runtime environment managing client-server connections (often the client application itself handles this).\n\n## Communication\n\nUses three message types: [^1]\n\n- **Requests**: Bidirectional, require unique ID and response\n- **Responses**: Reply with result or error, matching request ID \n- **Notifications**: One-way messages, no response expected\n\n## Examples\n\n**Server exposing a database**:\n```typescript\n// Server provides resources (database tables)\n// Client requests data via JSON-RPC\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"method\": \"resources/read\",\n \"params\": { \"uri\": \"db://users\" }\n}\n```\n\n**Client requesting LLM sampling**:\n```typescript\n// Server asks client to generate text\n{\n \"jsonrpc\": \"2.0\",\n \"id\": 2,\n \"method\": \"sampling/createMessage\",\n \"params\": { \"messages\": [...] }\n}\n```\n\n**Server exposing tools**:\n- File system server: read/write operations\n- API server: HTTP request tools\n- Calculator server: math functions\n\nBase protocol and lifecycle management are mandatory; other features are optional. [^1]","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">35</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">3,638</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.03 / 0.03</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">21.91</span>\n</li>\n\n","documents":[]},{"id":"3ef426e6-ac4a-4c81-816e-1f22619d91ef","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:33:22Z","state":"done","prompt":"Why the destination between client and host?","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" >Understanding MCP clients</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 100%, transparent 100%)\">100%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Understanding MCP clients](https://modelcontextprotocol.io/docs/learn/client-concepts) (100%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Model Context Protocol client host distinction</li></ul></summary> Sources (3):<br>\n<strong>Understanding MCP clients</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" target=\"_blank\">https://modelcontextprotocol.io/docs/learn/client-concepts</a><br>\nJul 25, 2025 Understanding the distinction is important: the host is the application users interact with, while clients are the protocol-level components that enable server ...\n\n<p><strong>Specification - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/specification/2025-03-26\" target=\"_blank\">https://modelcontextprotocol.io/specification/2025-03-26</a><br>\nNov 25, 2024 Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you’re building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need. This specification defines the authoritative protocol requirements, based on the TypeScript schema in schema.ts. For implementation guides and examples, visit modelcontextprotocol.io.</p>\n<p><strong>Build an MCP client - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" target=\"_blank\">https://modelcontextprotocol.io/docs/develop/build-client</a><br>\nDec 11, 2024 In this tutorial, you’ll learn how to build an LLM-powered chatbot client that connects to MCP servers.env=None ). stdio_transport = await self.exit_stack.enter_async_context(stdio_client(server_params)) self.stdio, self.write = stdio_transport self.session = await self.exit_stack.enter_async_context(ClientSession(self.stdio, self.write)).</p>\n</details><p>The distinction separates concerns: <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts#:~:text=Understanding%20the,enable%20server\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Understanding MCP clients</b></a><span class=\"passage\">Understanding the distinction is important: the host is the application users interact with, while clients are the protocol-level components that enable server ...</span></span></sup></p>\n<p><strong>Host</strong> = User-facing application (Claude Desktop, VS Code, etc.)</p>\n<ul>\n<li>Manages UI/UX</li>\n<li>Handles user interactions</li>\n<li>Orchestrates multiple clients</li>\n</ul>\n<p><strong>Client</strong> = Protocol implementation component</p>\n<ul>\n<li>Handles JSON-RPC communication</li>\n<li>Manages connection lifecycle</li>\n<li>Implements MCP specification</li>\n</ul>\n<h2>Why separate them?</h2>\n<p>A single host can manage multiple clients simultaneously, each connecting to different servers. For example, Claude Desktop (host) might run:</p>\n<ul>\n<li>Client A → File system server</li>\n<li>Client B → Database server</li>\n<li>Client C → API server</li>\n</ul>\n<p>This architecture allows the host to coordinate between multiple data sources while keeping protocol logic isolated in dedicated client components.</p>","md":"The distinction separates concerns: [^1]\n\n**Host** = User-facing application (Claude Desktop, VS Code, etc.)\n- Manages UI/UX\n- Handles user interactions\n- Orchestrates multiple clients\n\n**Client** = Protocol implementation component\n- Handles JSON-RPC communication\n- Manages connection lifecycle\n- Implements MCP specification\n\n## Why separate them?\n\nA single host can manage multiple clients simultaneously, each connecting to different servers. For example, Claude Desktop (host) might run:\n- Client A → File system server\n- Client B → Database server \n- Client C → API server\n\nThis architecture allows the host to coordinate between multiple data sources while keeping protocol logic isolated in dedicated client components.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">27</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">2,785</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.01 / 0.04</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">12.79</span>\n</li>\n\n","documents":[]},{"id":"c2054c29-8758-4957-9e05-abaaade12cb3","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:34:27Z","state":"done","prompt":"But what is the client in your last example?","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" >Understanding MCP clients</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 100%, transparent 100%)\">100%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Understanding MCP clients](https://modelcontextprotocol.io/docs/learn/client-concepts) (100%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Model Context Protocol client definition</li></ul></summary> Sources (3):<br>\n<strong>Understanding MCP clients</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" target=\"_blank\">https://modelcontextprotocol.io/docs/learn/client-concepts</a><br>\nJul 25, 2025 MCP clients are instantiated by host applications to communicate with particular MCP servers. The host application, like Claude.ai or an IDE, ...\n\n<p><strong>What is the Model Context Protocol (MCP)?</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/getting-started/intro\" target=\"_blank\">https://modelcontextprotocol.io/docs/getting-started/intro</a><br>\n MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems. Using MCP, AI applications like Claude or ChatGPT can connect to data sources (e.g. local files, databases), tools (e.g. search engines, calculators) and workflows (e.g. specialized prompts)—enabling them to access key information and perform tasks. Think of MCP like a USB-C port for ...</p>\n<p><strong>Specification - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/specification/2025-03-26\" target=\"_blank\">https://modelcontextprotocol.io/specification/2025-03-26</a><br>\nNov 25, 2024 Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you’re building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need. This specification defines the authoritative protocol requirements, based on the TypeScript schema in schema.ts.</p>\n</details><p>The <strong>client</strong> is the MCP protocol implementation instance within Claude Desktop that handles communication with one specific server. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts#:~:text=MCP%20clients,an%20IDE%2C\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Understanding MCP clients</b></a><span class=\"passage\">MCP clients are instantiated by host applications to communicate with particular MCP servers. The host application, like Claude.ai or an IDE, ...</span></span></sup></p>\n<p>In my example:</p>\n<ul>\n<li><strong>Host</strong>: Claude Desktop (the application)</li>\n<li><strong>Client A</strong>: MCP client instance #1 → connects to file system server</li>\n<li><strong>Client B</strong>: MCP client instance #2 → connects to database server</li>\n<li><strong>Client C</strong>: MCP client instance #3 → connects to API server</li>\n</ul>\n<p>Each client is a separate connection handler, not a separate application. Think of clients as connection objects or protocol adapters that the host instantiates and manages.</p>\n<p>The host creates multiple client instances to maintain concurrent connections to different servers.</p>","md":"The **client** is the MCP protocol implementation instance within Claude Desktop that handles communication with one specific server. [^1]\n\nIn my example:\n- **Host**: Claude Desktop (the application)\n- **Client A**: MCP client instance #1 → connects to file system server\n- **Client B**: MCP client instance #2 → connects to database server\n- **Client C**: MCP client instance #3 → connects to API server\n\nEach client is a separate connection handler, not a separate application. Think of clients as connection objects or protocol adapters that the host instantiates and manages.\n\nThe host creates multiple client instances to maintain concurrent connections to different servers.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">28</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">2,940</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.01 / 0.05</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">10.72</span>\n</li>\n\n","documents":[]},{"id":"f0692276-9a04-4010-b9f2-37af00c979a6","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:35:34Z","state":"done","prompt":"Okay. Five me the simplest client example code you can think of","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" >Build an MCP client - Model Context Protocol</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 100%, transparent 100%)\">100%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Build an MCP client - Model Context Protocol](https://modelcontextprotocol.io/docs/develop/build-client) (100%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Model Context Protocol client example</li></ul></summary> Sources (3):<br>\n<strong>Example Clients</strong><br>\n<a href=\"https://modelcontextprotocol.io/clients\" target=\"_blank\">https://modelcontextprotocol.io/clients</a><br>\nNov 25, 2024 This page provides an overview of applications that support the Model Context Protocol (MCP). Each client may support different MCP features, allowing for ...Jump to\n\n<p><strong>Build an MCP client - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" target=\"_blank\">https://modelcontextprotocol.io/docs/develop/build-client</a><br>\nDec 11, 2024 Get started building your own client that can integrate with all MCP servers.</p>\n<p><strong>Sampling</strong><br>\n<a href=\"https://modelcontextprotocol.io/specification/2025-06-18/client/sampling\" target=\"_blank\">https://modelcontextprotocol.io/specification/2025-06-18/client/sampling</a><br>\nJun 18, 2025 The Model Context Protocol (MCP) provides a standardized way for servers to request LLM sampling (“completions” or “generations”) from language models via clients. This flow allows clients to maintain control over model access, selection, and permissions while enabling servers to leverage AI capabilities—with no server API keys necessary. Servers can request text, audio, or image ...</p>\n</details>\n<details><summary>Gathered key details from:<p></p>\n<ul>\n<li><a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" target=\"_blank\">Build an MCP client - Model Context Protocol</a></li></ul></summary>\n\n<h3>Query</h3>\n<p>Give me the simplest client example code you can think of</p>\n<h3>Response</h3>\n<p>class MCPClient:<br>\n def <strong>init</strong>(self):</p>\n<h1>Initialize session and client objects</h1>\n<p>self.session: Optional[ClientSession] = None<br>\n self.exit_stack = AsyncExitStack()<br>\n self.anthropic = Anthropic()</p>\n<h1>methods will go here</h1>\n<hr>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code>async def connect_to_server(self, server_script_path: str):\n \"\"\"Connect to an MCP server\n\n Args:\n server_script_path: Path to the server script (.py or .js)\n \"\"\"\n is_python = server_script_path.endswith('.py')\n is_js = server_script_path.endswith('.js')\n if not (is_python or is_js):\n raise ValueError(\"Server script must be a .py or .js file\")\n\n command = \"python\" if is_python else \"node\"\n server_params = StdioServerParameters(\n command=command,\n args=[server_script_path],\n env=None\n )\n\n stdio_transport = await self.exit_stack.enter_async_context(stdio_client(server_params))\n self.stdio, self.write = stdio_transport\n self.session = await self.exit_stack.enter_async_context(ClientSession(self.stdio, self.write))\n\n await self.session.initialize()\n\n # List available tools\n response = await self.session.list_tools()\n tools = response.tools\n print(\"\\nConnected to server with tools:\", [tool.name for tool in tools])\n</code></pre></div>\n<hr>\n<p>async def process_query(self, query: str) -> str:<br>\n \"\"\"Process a query using Claude and available tools\"\"\"<br>\n messages = [<br>\n {<br>\n \"role\": \"user\",<br>\n \"content\": query<br>\n }<br>\n ]</p>\n<p>response = await self.session.list_tools()<br>\n available_tools = [{<br>\n \"name\": tool.name,<br>\n \"description\": tool.description,<br>\n \"input_schema\": tool.inputSchema<br>\n } for tool in response.tools]</p>\n<h1>Initial Claude API call</h1>\n<p>response = self.anthropic.messages.create(<br>\n model=\"claude-3-5-sonnet-20241022\",<br>\n max_tokens=1000,<br>\n messages=messages,<br>\n tools=available_tools<br>\n )</p>\n<h1>Process response and handle tool calls</h1>\n<p>final_text = []</p>\n<p>assistant_message_content = []<br>\n for content in response.content:<br>\n if content.type == 'text':<br>\n final_text.append(content.text)<br>\n assistant_message_content.append(content)<br>\n elif content.type == 'tool_use':<br>\n tool_name = content.name<br>\n tool_args = content.input</p>\n<h1>Execute tool call</h1>\n<p>result = await self.session.call_tool(tool_name, tool_args)<br>\n final_text.append(f\"[Calling tool {tool_name} with args {tool_args}]\")</p>\n<p>assistant_message_content.append(content)<br>\n messages.append({<br>\n \"role\": \"assistant\",<br>\n \"content\": assistant_message_content<br>\n })<br>\n messages.append({<br>\n \"role\": \"user\",<br>\n \"content\": [<br>\n {<br>\n \"type\": \"tool_result\",<br>\n \"tool_use_id\": content.id,<br>\n \"content\": result.content<br>\n }<br>\n ]<br>\n })</p>\n<h1>Get next response from Claude</h1>\n<p>response = self.anthropic.messages.create(<br>\n model=\"claude-3-5-sonnet-20241022\",<br>\n max_tokens=1000,<br>\n messages=messages,<br>\n tools=available_tools<br>\n )</p>\n<p>final_text.append(response.content[0].text)</p>\n<p>return \"\\n\".join(final_text)</p>\n<hr>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code>async def chat_loop(self):\n \"\"\"Run an interactive chat loop\"\"\"\n print(\"\\nMCP Client Started!\")\n print(\"Type your queries or 'quit' to exit.\")\n\n while True:\n try:\n query = input(\"\\nQuery: \").strip()\n\n if query.lower() == 'quit':\n break\n\n response = await self.process_query(query)\n print(\"\\n\" + response)\n\n except Exception as e:\n print(f\"\\nError: {str(e)}\")\n\nasync def cleanup(self):\n \"\"\"Clean up resources\"\"\"\n await self.exit_stack.aclose()\n\n\n---\n\nasync def main():\n if len(sys.argv) < 2:\n print(\"Usage: python client.py <path_to_server_script>\")\n sys.exit(1)\n\n client = MCPClient()\n try:\n await client.connect_to_server(sys.argv[1])\n await client.chat_loop()\n finally:\n await client.cleanup()\n\nif __name__ == \"__main__\":\n import sys\n asyncio.run(main())\n</code></pre></div>\n</details><div class=\"codehilite\"><span class=\"filename\">Python</span><pre><span></span><code><span class=\"kn\">import</span> <span class=\"n\">asyncio</span>\n<span class=\"kr\">from</span> <span class=\"n\">mcp</span> <span class=\"kn\">import</span> <span class=\"n\">ClientSession</span><span class=\"p\">,</span> <span class=\"n\">StdioServerParameters</span>\n<span class=\"kr\">from</span> <span class=\"n\">mcp</span><span class=\"p\">.</span><span class=\"n\">client</span><span class=\"p\">.</span><span class=\"n\">stdio</span> <span class=\"kn\">import</span> <span class=\"n\">stdio_client</span>\n<span class=\"kr\">from</span> <span class=\"n\">contextlib</span> <span class=\"kn\">import</span> <span class=\"n\">AsyncExitStack</span>\n\n<span class=\"k\">class</span> <span class=\"n\">MCPClient</span><span class=\"p\">:</span>\n <span class=\"kd\">def</span> <span class=\"n\">__init__</span><span class=\"p\">(</span><span class=\"n\">self</span><span class=\"p\">)</span><span class=\"p\">:</span>\n <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">session</span> <span class=\"o\">=</span> <span class=\"kc\">None</span>\n <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">exit_stack</span> <span class=\"o\">=</span> <span class=\"n\">AsyncExitStack</span><span class=\"p\">(</span><span class=\"p\">)</span>\n\n <span class=\"k\">async</span> <span class=\"kd\">def</span> <span class=\"n\">connect</span><span class=\"p\">(</span><span class=\"n\">self</span><span class=\"p\">,</span> <span class=\"n\">server_script</span><span class=\"p\">)</span><span class=\"p\">:</span>\n <span class=\"c\"># Setup stdio transport</span>\n <span class=\"n\">server_params</span> <span class=\"o\">=</span> <span class=\"n\">StdioServerParameters</span><span class=\"p\">(</span>\n <span class=\"n\">command</span><span class=\"o\">=</span><span class=\"s\">\"node\"</span><span class=\"p\">,</span> <span class=\"c\"># or \"python\"</span>\n <span class=\"n\">args</span><span class=\"o\">=</span><span class=\"p\">[</span><span class=\"n\">server_script</span><span class=\"p\">]</span>\n <span class=\"p\">)</span>\n\n <span class=\"n\">stdio_transport</span> <span class=\"o\">=</span> <span class=\"kr\">await</span> <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">exit_stack</span><span class=\"p\">.</span><span class=\"n\">enter_async_context</span><span class=\"p\">(</span>\n <span class=\"n\">stdio_client</span><span class=\"p\">(</span><span class=\"n\">server_params</span><span class=\"p\">)</span>\n <span class=\"p\">)</span>\n <span class=\"n\">stdio</span><span class=\"p\">,</span> <span class=\"n\">write</span> <span class=\"o\">=</span> <span class=\"n\">stdio_transport</span>\n\n <span class=\"c\"># Create session</span>\n <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">session</span> <span class=\"o\">=</span> <span class=\"kr\">await</span> <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">exit_stack</span><span class=\"p\">.</span><span class=\"n\">enter_async_context</span><span class=\"p\">(</span>\n <span class=\"n\">ClientSession</span><span class=\"p\">(</span><span class=\"n\">stdio</span><span class=\"p\">,</span> <span class=\"n\">write</span><span class=\"p\">)</span>\n <span class=\"p\">)</span>\n\n <span class=\"kr\">await</span> <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">session</span><span class=\"p\">.</span><span class=\"n\">initialize</span><span class=\"p\">(</span><span class=\"p\">)</span>\n\n <span class=\"c\"># List available tools</span>\n <span class=\"n\">response</span> <span class=\"o\">=</span> <span class=\"kr\">await</span> <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">session</span><span class=\"p\">.</span><span class=\"n\">list_tools</span><span class=\"p\">(</span><span class=\"p\">)</span>\n <span class=\"n\">print</span><span class=\"p\">(</span><span class=\"s\">\"Tools:\"</span><span class=\"p\">,</span> <span class=\"p\">[</span><span class=\"n\">t</span><span class=\"p\">.</span><span class=\"n\">name</span> <span class=\"kr\">for</span> <span class=\"n\">t</span> <span class=\"ow\">in</span> <span class=\"n\">response</span><span class=\"p\">.</span><span class=\"n\">tools</span><span class=\"p\">]</span><span class=\"p\">)</span>\n\n <span class=\"k\">async</span> <span class=\"kd\">def</span> <span class=\"n\">cleanup</span><span class=\"p\">(</span><span class=\"n\">self</span><span class=\"p\">)</span><span class=\"p\">:</span>\n <span class=\"kr\">await</span> <span class=\"n\">self</span><span class=\"p\">.</span><span class=\"n\">exit_stack</span><span class=\"p\">.</span><span class=\"n\">aclose</span><span class=\"p\">(</span><span class=\"p\">)</span>\n\n<span class=\"k\">async</span> <span class=\"kd\">def</span> <span class=\"n\">main</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">:</span>\n <span class=\"n\">client</span> <span class=\"o\">=</span> <span class=\"n\">MCPClient</span><span class=\"p\">(</span><span class=\"p\">)</span>\n <span class=\"kr\">try</span><span class=\"p\">:</span>\n <span class=\"kr\">await</span> <span class=\"n\">client</span><span class=\"p\">.</span><span class=\"n\">connect</span><span class=\"p\">(</span><span class=\"s\">\"server.js\"</span><span class=\"p\">)</span>\n <span class=\"c\"># Use client.session to call tools</span>\n <span class=\"kr\">finally</span><span class=\"p\">:</span>\n <span class=\"kr\">await</span> <span class=\"n\">client</span><span class=\"p\">.</span><span class=\"n\">cleanup</span><span class=\"p\">(</span><span class=\"p\">)</span>\n\n<span class=\"n\">asyncio</span><span class=\"p\">.</span><span class=\"n\">run</span><span class=\"p\">(</span><span class=\"n\">main</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">)</span>\n</code></pre></div>\n<p>Core components: <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/docs/develop/build-client#:~:text=%60%60%60%20async,tools%5D%29%20%60%60%60\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Build an MCP client - Model Context Protocol</b></a><span class=\"passage\">``` async def connect_to_server(self, server_script_path: str): \"\"\"Connect to an MCP server Args: server_script_path: Path to the server script (.py or .js) \"\"\" is_python = server_script_path.endswith('.py') is_js = server_script_path.endswith('.js') if not (is_python or is_js): raise ValueError(\"Server script must be a .py or .js file\") command = \"python\" if is_python else \"node\" server_params = StdioServerParameters( command=command, args=[server_script_path], env=None ) stdio_transport = ...</span></span></sup></p>\n<ul>\n<li><code>ClientSession</code>: Manages JSON-RPC communication</li>\n<li><code>stdio_client</code>: Creates stdio transport for subprocess</li>\n<li><code>AsyncExitStack</code>: Handles async resource cleanup</li>\n<li><code>initialize()</code>: Performs MCP handshake</li>\n<li><code>list_tools()</code>: Discovers server capabilities</li>\n</ul>","md":"```python\nimport asyncio\nfrom mcp import ClientSession, StdioServerParameters\nfrom mcp.client.stdio import stdio_client\nfrom contextlib import AsyncExitStack\n\nclass MCPClient:\n def __init__(self):\n self.session = None\n self.exit_stack = AsyncExitStack()\n \n async def connect(self, server_script):\n # Setup stdio transport\n server_params = StdioServerParameters(\n command=\"node\", # or \"python\"\n args=[server_script]\n )\n \n stdio_transport = await self.exit_stack.enter_async_context(\n stdio_client(server_params)\n )\n stdio, write = stdio_transport\n \n # Create session\n self.session = await self.exit_stack.enter_async_context(\n ClientSession(stdio, write)\n )\n \n await self.session.initialize()\n \n # List available tools\n response = await self.session.list_tools()\n print(\"Tools:\", [t.name for t in response.tools])\n \n async def cleanup(self):\n await self.exit_stack.aclose()\n\nasync def main():\n client = MCPClient()\n try:\n await client.connect(\"server.js\")\n # Use client.session to call tools\n finally:\n await client.cleanup()\n\nasyncio.run(main())\n```\n\nCore components: [^1]\n- `ClientSession`: Manages JSON-RPC communication\n- `stdio_client`: Creates stdio transport for subprocess\n- `AsyncExitStack`: Handles async resource cleanup\n- `initialize()`: Performs MCP handshake\n- `list_tools()`: Discovers server capabilities","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">52</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">4,495</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.02 / 0.07</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">17.11</span>\n</li>\n\n","documents":[]},{"id":"ccef7083-6154-47fd-80f4-03421adc3cae","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:36:05Z","state":"done","prompt":"In Nodejs ","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.info/docs/tutorials/building-a-client-node/\" >Building MCP clients-Node.js – Model Context Protocol (MCP)</a>\n <span class=\"__domain-name\">modelcontextprotocol.info</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 100%, transparent 100%)\">100%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Building MCP clients-Node.js – Model Context Protocol (MCP)](https://modelcontextprotocol.info/docs/tutorials/building-a-client-node/) (100%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>MCP client example Node.js</li></ul></summary> Sources (3):<br>\n<strong>Building MCP clients-Node.js</strong><br>\n<a href=\"https://modelcontextprotocol.info/docs/tutorials/building-a-client-node/\" target=\"_blank\">https://modelcontextprotocol.info/docs/tutorials/building-a-client-node/</a><br>\nBuilding MCP clients-Node.js · System Requirements · Setting Up Your Environment · Setting Up Your API Key · Creating the Client · Server Connection Management.\n\n<p><strong>Build an MCP client - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" target=\"_blank\">https://modelcontextprotocol.io/docs/develop/build-client</a><br>\nDec 11, 2024 Get started building your own client that can integrate with all MCP servers.</p>\n<p><strong>An MCP client for Node.js.</strong><br>\n<a href=\"https://github.com/punkpeye/mcp-client\" target=\"_blank\">https://github.com/punkpeye/mcp-client</a><br>\n An MCP client for Node.js. Contribute to punkpeye/mcp-client development by creating an account on GitHub.</p>\n</details>\n<details><summary>Gathered key details from:<p></p>\n<ul>\n<li><a href=\"https://modelcontextprotocol.info/docs/tutorials/building-a-client-node/\" target=\"_blank\">Building MCP clients-Node.js – Model Context Protocol (MCP)</a></li></ul></summary>\n\n<h3>Query</h3>\n<p>simplest client example code in Node.js</p>\n<h3>Response</h3>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code>import { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { StdioClientTransport } from \"@modelcontextprotocol/sdk/client/stdio.js\";\nimport Anthropic from \"@anthropic-ai/sdk\";\nimport dotenv from \"dotenv\";\nimport { Tool } from \"@anthropic-ai/sdk/resources/messages.js\";\nimport {\n CallToolResultSchema,\n ListToolsResultSchema,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport * as readline from \"node:readline\";\n\ndotenv.config();\n\ninterface MCPClientConfig {\n name?: string;\n version?: string;\n}\n\nclass MCPClient {\n private client: Client | null = null;\n private anthropic: Anthropic;\n private transport: StdioClientTransport | null = null;\n\n constructor(config: MCPClientConfig = {}) {\n this.anthropic = new Anthropic();\n }\n\n // Methods will go here\n}\n</code></pre></div>\n<hr>\n<p>Next, implement the method to connect to an MCP server:</p>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code> async connectToServer(serverScriptPath: string): Promise<void> {\n const isPython = serverScriptPath.endsWith(\".py\");\n const isJs = serverScriptPath.endsWith(\".js\");\n\n if (!isPython && !isJs) {\n throw new Error(\"Server script must be a .py or .js file\");\n }\n\n const command = isPython ? \"python\" : \"node\";\n\n this.transport = new StdioClientTransport({\n command,\n args: [serverScriptPath],\n });\n\n this.client = new Client(\n {\n name: \"mcp-client\",\n version: \"1.0.0\",\n },\n {\n capabilities: {},\n }\n );\n\n await this.client.connect(this.transport);\n\n // List available tools\n const response = await this.client.request(\n { method: \"tools/list\" },\n ListToolsResultSchema\n );\n\n console.log(\n \"\\nConnected to server with tools:\",\n response.tools.map((tool: any) => tool.name)\n );\n }\n\n---\n\n\nNow add the core functionality for processing queries and handling tool calls:\n</code></pre></div>\n<p>async processQuery(query: string): Promise<string> {<br>\n if (!this.client) {<br>\n throw new Error(\"Client not connected\");<br>\n }</p>\n<p>// Initialize messages array with user query<br>\n let messages: Anthropic.MessageParam[] = [<br>\n {<br>\n role: \"user\",<br>\n content: query,<br>\n },<br>\n ];</p>\n<p>// Get available tools<br>\n const toolsResponse = await this.client.request(<br>\n { method: \"tools/list\" },<br>\n ListToolsResultSchema<br>\n );</p>\n<p>const availableTools: Tool[] = toolsResponse.tools.map((tool: any) => ({<br>\n name: tool.name,<br>\n description: tool.description,<br>\n input_schema: tool.inputSchema,<br>\n }));</p>\n<p>const finalText: string[] = [];<br>\n let currentResponse = await this.anthropic.messages.create({<br>\n model: \"claude-3-5-sonnet-20241022\",<br>\n max_tokens: 1000,<br>\n messages,<br>\n tools: availableTools,<br>\n });</p>\n<p>// Process the response and any tool calls<br>\n while (true) {<br>\n // Add Claude's response to final text and messages<br>\n for (const content of currentResponse.content) {<br>\n if (content.type === \"text\") {<br>\n finalText.push(content.text);<br>\n } else if (content.type === \"tool_use\") {<br>\n const toolName = content.name;<br>\n const toolArgs = content.input;</p>\n<p>// Execute tool call<br>\n const result = await this.client.request(<br>\n {<br>\n method: \"tools/call\",<br>\n params: {<br>\n name: toolName,<br>\n args: toolArgs,<br>\n },<br>\n },<br>\n CallToolResultSchema<br>\n );</p>\n<p>finalText.push(<br>\n <code>[Calling tool ${toolName} with args ${JSON.stringify(toolArgs)}]</code><br>\n );</p>\n<p>// Add Claude's response (including tool use) to messages<br>\n messages.push({<br>\n role: \"assistant\",<br>\n content: currentResponse.content,<br>\n });</p>\n<p>// Add tool result to messages<br>\n messages.push({<br>\n role: \"user\",<br>\n content: [<br>\n {<br>\n type: \"tool_result\",<br>\n tool_use_id: content.id,<br>\n content: [<br>\n { type: \"text\", text: JSON.stringify(result.content) },<br>\n ],<br>\n },<br>\n ],<br>\n });</p>\n<p>// Get next response from Claude with tool results<br>\n currentResponse = await this.anthropic.messages.create({<br>\n model: \"claude-3-5-sonnet-20241022\",<br>\n max_tokens: 1000,<br>\n messages,<br>\n tools: availableTools,<br>\n });</p>\n<p>// Add Claude's interpretation of the tool results to final text<br>\n if (currentResponse.content[0]?.type === \"text\") {<br>\n finalText.push(currentResponse.content[0].text);<br>\n }</p>\n<p>// Continue the loop to process any additional tool calls<br>\n continue;<br>\n }<br>\n }</p>\n<p>// If we reach here, there were no tool calls in the response<br>\n break;<br>\n }</p>\n<p>return finalText.join(\"\\n\");<br>\n }</p>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code>\n---\n\n\nAdd the chat loop and cleanup functionality:\n</code></pre></div>\n<p>async chatLoop(): Promise<void> {<br>\n console.log(\"\\nMCP Client Started!\");<br>\n console.log(\"Type your queries or 'quit' to exit.\");</p>\n<p>// Using Node's readline for console input<br>\n const rl = readline.createInterface({<br>\n input: process.stdin,<br>\n output: process.stdout,<br>\n });</p>\n<p>const askQuestion = () => {<br>\n rl.question(\"\\nQuery: \", async (query: string) => {<br>\n try {<br>\n if (query.toLowerCase() === \"quit\") {<br>\n await this.cleanup();<br>\n rl.close();<br>\n return;<br>\n }</p>\n<p>const response = await this.processQuery(query);<br>\n console.log(\"\\n\" + response);<br>\n askQuestion();<br>\n } catch (error) {<br>\n console.error(\"\\nError:\", error);<br>\n askQuestion();<br>\n }<br>\n });<br>\n };</p>\n<p>askQuestion();<br>\n }</p>\n<p>async cleanup(): Promise<void> {<br>\n if (this.transport) {<br>\n await this.transport.close();<br>\n }<br>\n }</p>\n<div class=\"codehilite\"><span class=\"filename\"></span><pre><span></span><code>\n---\n\n## Main Entry Point \n\nFinally, add the main execution logic outside the class:\n</code></pre></div>\n<p>// Main execution<br>\nasync function main() {<br>\n if (process.argv.length < 3) {<br>\n console.log(\"Usage: ts-node client.ts <path_to_server_script>\");<br>\n process.exit(1);<br>\n }</p>\n<p>const client = new MCPClient();<br>\n try {<br>\n await client.connectToServer(process.argv[2]);<br>\n await client.chatLoop();<br>\n } catch (error) {<br>\n console.error(\"Error:\", error);<br>\n await client.cleanup();<br>\n process.exit(1);<br>\n }<br>\n}</p>\n<p>// Run main if this is the main module<br>\nif (import.meta.url === new URL(process.argv[1], \"file:\").href) {<br>\n main();<br>\n}</p>\n<p>export default MCPClient;</p>\n<div class=\"codehilite\"><span class=\"filename\"></details></span><pre><span></span><code></code></pre></div></details><div class=\"codehilite\"><span class=\"filename\">Typescript</span><pre><span></span><code>import { <span class=\"kt\">Client</span> } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { <span class=\"kt\">StdioClientTransport</span> } from \"@modelcontextprotocol/sdk/client/stdio.js\";\n\nclass <span class=\"kt\">MCPClient</span> {\n <span class=\"k\">private</span> client: <span class=\"kt\">Client</span>;\n <span class=\"k\">private</span> transport: <span class=\"kt\">StdioClientTransport</span>;\n\n async connect(<span class=\"n\">serverScript</span>: <span class=\"kt\">string</span>) {\n // Create stdio transport to server process\n this.transport = new <span class=\"kt\">StdioClientTransport</span>({\n command: \"node\", // or \"python\"\n args: [serverScript]\n });\n\n // Initialize client\n this.client = new <span class=\"kt\">Client</span>(\n { name: \"simple-client\", version: \"1.0.0\" },\n { capabilities: {} }\n );\n\n await this.client.connect(this.transport);\n\n // List available tools\n const tools = await this.client.request(\n { method: \"tools/list\" },\n <span class=\"kt\">ListToolsResultSchema</span>\n );\n\n console.log(\"Tools:\", tools.tools.map(t => t.name));\n }\n\n async cleanup() {\n await this.transport.close();\n }\n}\n\n// Usage\nconst client = new <span class=\"kt\">MCPClient</span>();\nawait client.connect(\"./server.js\");\nawait client.cleanup();\n</code></pre></div>\n<p>Key components: <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.info/docs/tutorials/building-a-client-node/\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.info/docs/tutorials/building-a-client-node/#:~:text=%60%60%60%20import,%7D%20%60%60%60\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH8122vYRtA6LCPdQ4CMuNYBPAIHlL7ivL69D6NgEj7PC\"> modelcontextprotocol.info</span><b>1. Building MCP clients-Node.js – Model Context Protocol (MCP)</b></a><span class=\"passage\">``` import { Client } from \"@modelcontextprotocol/sdk/client/index.js\"; import { StdioClientTransport } from \"@modelcontextprotocol/sdk/client/stdio.js\"; import Anthropic from \"@anthropic-ai/sdk\"; import dotenv from \"dotenv\"; import { Tool } from \"@anthropic-ai/sdk/resources/messages.js\"; import { CallToolResultSchema, ListToolsResultSchema, } from \"@modelcontextprotocol/sdk/types.js\"; import * as readline from \"node:readline\"; dotenv.config(); interface MCPClientConfig { name?: string; ...</span></span></sup></p>\n<ul>\n<li><code>StdioClientTransport</code>: Spawns server as subprocess, handles stdio communication</li>\n<li><code>Client</code>: Manages JSON-RPC protocol</li>\n<li><code>connect()</code>: Establishes connection and initializes session</li>\n<li><code>request()</code>: Sends JSON-RPC requests to server</li>\n</ul>","md":"```typescript\nimport { Client } from \"@modelcontextprotocol/sdk/client/index.js\";\nimport { StdioClientTransport } from \"@modelcontextprotocol/sdk/client/stdio.js\";\n\nclass MCPClient {\n private client: Client;\n private transport: StdioClientTransport;\n\n async connect(serverScript: string) {\n // Create stdio transport to server process\n this.transport = new StdioClientTransport({\n command: \"node\", // or \"python\"\n args: [serverScript]\n });\n\n // Initialize client\n this.client = new Client(\n { name: \"simple-client\", version: \"1.0.0\" },\n { capabilities: {} }\n );\n\n await this.client.connect(this.transport);\n\n // List available tools\n const tools = await this.client.request(\n { method: \"tools/list\" },\n ListToolsResultSchema\n );\n \n console.log(\"Tools:\", tools.tools.map(t => t.name));\n }\n\n async cleanup() {\n await this.transport.close();\n }\n}\n\n// Usage\nconst client = new MCPClient();\nawait client.connect(\"./server.js\");\nawait client.cleanup();\n```\n\nKey components: [^1]\n- `StdioClientTransport`: Spawns server as subprocess, handles stdio communication\n- `Client`: Manages JSON-RPC protocol\n- `connect()`: Establishes connection and initializes session\n- `request()`: Sends JSON-RPC requests to server","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">56</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">6,896</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.03 / 0.10</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">17.11</span>\n</li>\n\n","documents":[]},{"id":"17fab220-11bf-42a0-8712-fe3aa87acce8","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:37:40Z","state":"done","prompt":"What would that be without the modelcontextprotocol/sdk","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://nodejs.org/api/child_process.html\" >Child process | Node.js v25.1.0 Documentation</a>\n <span class=\"__domain-name\">nodejs.org</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 60%, transparent 60%)\">60%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.json-rpc.dev/learn/examples\" >JSON-RPC Examples | JSON-RPC Tools</a>\n <span class=\"__domain-name\">www.json-rpc.dev</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 40%, transparent 40%)\">40%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Child process | Node.js v25.1.0 Documentation](https://nodejs.org/api/child_process.html) (60%)\n[^2]: [JSON-RPC Examples | JSON-RPC Tools](https://www.json-rpc.dev/learn/examples) (40%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>nodejs json-rpc client example</li>\n<li>nodejs child_process stdio communication</li></ul></summary> Sources (6):<br>\n<strong>Writing an RPC library in Node.js | by Fernando Doglio</strong><br>\n<a href=\"https://blog.bitsrc.io/writing-an-rpc-library-in-node-js-673632413f5f\" target=\"_blank\">https://blog.bitsrc.io/writing-an-rpc-library-in-node-js-673632413f5f</a><br>\nOct 03, 2019 Creating an RPC server Here is a full example of how you'd setup a JSON-WSP server with jWhisper: Notice how the code defines a class, called ( ...\n\n<p><strong>JSON-RPC Examples | JSON-RPC Tools</strong><br>\n<a href=\"https://www.json-rpc.dev/learn/examples\" target=\"_blank\">https://www.json-rpc.dev/learn/examples</a><br>\nApr 17, 2025 A simple implementation of a JSON-RPC 2.0 server and client using JavaScript and Node.js.</p>\n<p><strong>JSON-RPC Basic Client-Server Example</strong><br>\n<a href=\"https://json-rpc.dev/learn/examples/basic-client-server\" target=\"_blank\">https://json-rpc.dev/learn/examples/basic-client-server</a><br>\nApr 22, 2025 Professional JSON-RPC validation, generation, testing, and conversion tools for developers. Complete toolkit with multi-language support.</p>\n<p><strong>Child process | Node.js v25.1.0 Documentation</strong><br>\n<a href=\"https://nodejs.org/api/child_process.html\" target=\"_blank\">https://nodejs.org/api/child_process.html</a><br>\nJul 31, 2013 The node:child_process module provides the ability to spawn subprocesses in a manner that is similar, but not identical, to popen(3).</p>\n<p><strong>Child Process | Node.js v8.4.0 Documentation</strong><br>\n<a href=\"https://nodejs.org/download/release/v8.4.0/docs/api/child_process.html\" target=\"_blank\">https://nodejs.org/download/release/v8.4.0/docs/api/child_process.html</a><br>\n The child_process module provides the ability to spawn child processes in a manner that is similar, but not identical, to popen(3).</p>\n<p><strong>Child Process | Node.js v6.8.0 Documentation</strong><br>\n<a href=\"https://nodejs.org/download/release/v6.8.0/docs/api/child_process.html\" target=\"_blank\">https://nodejs.org/download/release/v6.8.0/docs/api/child_process.html</a><br>\n The child_process module in Node.js spawns child processes, similar to popen(3), using methods like `spawn()`, `exec()`, and `fork()`.</p>\n</details><div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"k\">import</span> <span class=\"p\">{</span> <span class=\"n\">spawn</span> <span class=\"p\">}</span> <span class=\"k\">from</span> <span class=\"s\">\"child_process\"</span><span class=\"p\">;</span>\n<span class=\"k\">import</span> <span class=\"p\">{</span> <span class=\"n\">createInterface</span> <span class=\"p\">}</span> <span class=\"k\">from</span> <span class=\"s\">\"readline\"</span><span class=\"p\">;</span>\n\n<span class=\"k\">class</span> <span class=\"nf\">MCPClient</span> <span class=\"p\">{</span>\n <span class=\"nf\">constructor</span><span class=\"p\">(</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>process <span class=\"o\">=</span> <span class=\"kc\">null</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>messageId <span class=\"o\">=</span> 0<span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests <span class=\"o\">=</span> <span class=\"k\">new</span> <span class=\"nf\">Map</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"nf\">connect</span><span class=\"p\">(</span><span class=\"n\">serverScript</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"c\">// Spawn server process</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>process <span class=\"o\">=</span> <span class=\"nf\">spawn</span><span class=\"p\">(</span><span class=\"s\">\"node\"</span><span class=\"p\">,</span> <span class=\"p\">[</span><span class=\"n\">serverScript</span><span class=\"p\">]</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Setup line-by-line reading from stdout</span>\n <span class=\"k\">const</span> <span class=\"n\">rl</span> <span class=\"o\">=</span> <span class=\"nf\">createInterface</span><span class=\"p\">(</span><span class=\"p\">{</span>\n input: <span class=\"nb\">this</span><span class=\"p\">.</span>process<span class=\"p\">.</span>stdout<span class=\"p\">,</span>\n crlfDelay: <span class=\"nf\">Infinity</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Handle incoming messages</span>\n <span class=\"n\">rl</span><span class=\"p\">.</span><span class=\"nf\">on</span><span class=\"p\">(</span><span class=\"s\">\"line\"</span><span class=\"p\">,</span> <span class=\"p\">(</span><span class=\"n\">line</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">message</span> <span class=\"o\">=</span> <span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">parse</span><span class=\"p\">(</span><span class=\"n\">line</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>id <span class=\"o\">&&</span> <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">has</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"p\">{</span> resolve<span class=\"p\">,</span> reject <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">get</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">delete</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>error<span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nf\">reject</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>error<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span> <span class=\"k\">else</span> <span class=\"p\">{</span>\n <span class=\"nf\">resolve</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>result<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"nb\">this</span><span class=\"p\">.</span>process<span class=\"p\">.</span>stderr<span class=\"p\">.</span><span class=\"nf\">on</span><span class=\"p\">(</span><span class=\"s\">\"data\"</span><span class=\"p\">,</span> <span class=\"p\">(</span><span class=\"n\">data</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">error</span><span class=\"p\">(</span><span class=\"s\">\"Server error:\"</span><span class=\"p\">,</span> <span class=\"n\">data</span><span class=\"p\">.</span><span class=\"nf\">toString</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">return</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">initialize</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"n\">method</span><span class=\"p\">,</span> <span class=\"n\">params</span> <span class=\"o\">=</span> <span class=\"p\">{</span><span class=\"p\">}</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">id</span> <span class=\"o\">=</span> <span class=\"o\">++</span><span class=\"nb\">this</span><span class=\"p\">.</span>messageId<span class=\"p\">;</span>\n <span class=\"k\">const</span> <span class=\"n\">message</span> <span class=\"o\">=</span> <span class=\"p\">{</span>\n jsonrpc: <span class=\"s\">\"2.0\"</span><span class=\"p\">,</span>\n id<span class=\"p\">,</span>\n method<span class=\"p\">,</span>\n params\n <span class=\"p\">}</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Send JSON-RPC request</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>process<span class=\"p\">.</span>stdin<span class=\"p\">.</span><span class=\"nf\">write</span><span class=\"p\">(</span><span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">stringify</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">)</span> <span class=\"o\">+</span> <span class=\"s\">\"\\n\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Wait for response</span>\n <span class=\"k\">return</span> <span class=\"k\">new</span> <span class=\"nf\">Promise</span><span class=\"p\">(</span><span class=\"p\">(</span><span class=\"n\">resolve</span><span class=\"p\">,</span> <span class=\"n\">reject</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">set</span><span class=\"p\">(</span><span class=\"n\">id</span><span class=\"p\">,</span> <span class=\"p\">{</span> resolve<span class=\"p\">,</span> reject <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">initialize</span><span class=\"p\">(</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">return</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"initialize\"</span><span class=\"p\">,</span> <span class=\"p\">{</span>\n protocolVersion: <span class=\"s\">\"2024-11-05\"</span><span class=\"p\">,</span>\n capabilities: <span class=\"p\">{</span><span class=\"p\">}</span><span class=\"p\">,</span>\n clientInfo: <span class=\"p\">{</span> name: <span class=\"s\">\"simple-client\"</span><span class=\"p\">,</span> version: <span class=\"s\">\"1.0.0\"</span> <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">listTools</span><span class=\"p\">(</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">return</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"tools/list\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"nf\">cleanup</span><span class=\"p\">(</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>process<span class=\"p\">.</span><span class=\"nf\">kill</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n<span class=\"p\">}</span>\n\n<span class=\"c\">// Usage</span>\n<span class=\"k\">const</span> <span class=\"n\">client</span> <span class=\"o\">=</span> <span class=\"k\">new</span> <span class=\"nf\">MCPClient</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"k\">await</span> <span class=\"n\">client</span><span class=\"p\">.</span><span class=\"nf\">connect</span><span class=\"p\">(</span><span class=\"s\">\"./server.js\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"k\">const</span> <span class=\"n\">tools</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"n\">client</span><span class=\"p\">.</span><span class=\"nf\">listTools</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">\"Tools:\"</span><span class=\"p\">,</span> <span class=\"n\">tools</span><span class=\"p\">.</span>tools<span class=\"p\">.</span><span class=\"nf\">map</span><span class=\"p\">(</span><span class=\"n\">t</span> <span class=\"o\">=></span> <span class=\"n\">t</span><span class=\"p\">.</span>name<span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"n\">client</span><span class=\"p\">.</span><span class=\"nf\">cleanup</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n</code></pre></div>\n<p>Core mechanics: <sup class=\"trigger\"><a href=\"https://www.json-rpc.dev/learn/examples\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.json-rpc.dev/learn/examples#:~:text=A%20simple,and%20Node.js.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJH-rZ53kQ7FB0T7Dy5pR6oXd7hNbVS32J_rQdcN8EnNU%3D\"> www.json-rpc.dev</span><b>2. JSON-RPC Examples | JSON-RPC Tools</b></a><span class=\"passage\">A simple implementation of a JSON-RPC 2.0 server and client using JavaScript and Node.js.</span></span></sup><sup class=\"trigger\"><a href=\"https://nodejs.org/api/child_process.html\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://nodejs.org/api/child_process.html#:~:text=The%20node%3Achild_process,to%20popen%283%29.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJV83SpG8FhY6-0nGg1A10MzyRNWP-HGPmHfp3Ku9lqu8%3D\"> nodejs.org</span><b>1. Child process | Node.js v25.1.0 Documentation</b></a><span class=\"passage\">The node:child_process module provides the ability to spawn subprocesses in a manner that is similar, but not identical, to popen(3).</span></span></sup></p>\n<ul>\n<li><code>spawn()</code>: Creates server subprocess</li>\n<li><code>readline</code>: Parses newline-delimited JSON messages</li>\n<li><code>pendingRequests</code>: Maps request IDs to Promise resolvers</li>\n<li><code>stdin.write()</code>: Sends JSON-RPC messages</li>\n<li>Each message is one line of JSON</li>\n</ul>","md":"```javascript\nimport { spawn } from \"child_process\";\nimport { createInterface } from \"readline\";\n\nclass MCPClient {\n constructor() {\n this.process = null;\n this.messageId = 0;\n this.pendingRequests = new Map();\n }\n\n connect(serverScript) {\n // Spawn server process\n this.process = spawn(\"node\", [serverScript]);\n\n // Setup line-by-line reading from stdout\n const rl = createInterface({\n input: this.process.stdout,\n crlfDelay: Infinity\n });\n\n // Handle incoming messages\n rl.on(\"line\", (line) => {\n const message = JSON.parse(line);\n \n if (message.id && this.pendingRequests.has(message.id)) {\n const { resolve, reject } = this.pendingRequests.get(message.id);\n this.pendingRequests.delete(message.id);\n \n if (message.error) {\n reject(message.error);\n } else {\n resolve(message.result);\n }\n }\n });\n\n this.process.stderr.on(\"data\", (data) => {\n console.error(\"Server error:\", data.toString());\n });\n\n return this.initialize();\n }\n\n async request(method, params = {}) {\n const id = ++this.messageId;\n const message = {\n jsonrpc: \"2.0\",\n id,\n method,\n params\n };\n\n // Send JSON-RPC request\n this.process.stdin.write(JSON.stringify(message) + \"\\n\");\n\n // Wait for response\n return new Promise((resolve, reject) => {\n this.pendingRequests.set(id, { resolve, reject });\n });\n }\n\n async initialize() {\n return this.request(\"initialize\", {\n protocolVersion: \"2024-11-05\",\n capabilities: {},\n clientInfo: { name: \"simple-client\", version: \"1.0.0\" }\n });\n }\n\n async listTools() {\n return this.request(\"tools/list\");\n }\n\n cleanup() {\n this.process.kill();\n }\n}\n\n// Usage\nconst client = new MCPClient();\nawait client.connect(\"./server.js\");\nconst tools = await client.listTools();\nconsole.log(\"Tools:\", tools.tools.map(t => t.name));\nclient.cleanup();\n```\n\nCore mechanics: [^2][^1]\n- `spawn()`: Creates server subprocess\n- `readline`: Parses newline-delimited JSON messages\n- `pendingRequests`: Maps request IDs to Promise resolvers\n- `stdin.write()`: Sends JSON-RPC messages\n- Each message is one line of JSON","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">62</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">5,008</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.02 / 0.12</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">15.13</span>\n</li>\n\n","documents":[]},{"id":"da08782d-2763-4356-9cda-904645b0f6d8","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:45:05Z","state":"done","prompt":"Now a barebones server.js example without modules","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" >Understanding MCP clients</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 100%, transparent 100%)\">100%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Understanding MCP clients](https://modelcontextprotocol.io/docs/learn/client-concepts) (100%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>MCP server example nodejs without modules</li></ul></summary> Sources (3):<br>\n<strong>MCP Server in Node.js</strong><br>\n<a href=\"https://github.com/lucianoayres/mcp-server-node\" target=\"_blank\">https://github.com/lucianoayres/mcp-server-node</a><br>\nMar 22, 2025 MCP Server implemented in JavaScript using Node.js that demonstrates how to build an MCP server with a custom prompt and custom tools, including one that loads ...\n\n<p><strong>GitHub - iamtraction/node-mcp-server: A sample Node.js MCP Server ...</strong><br>\n<a href=\"https://github.com/iamtraction/node-mcp-server\" target=\"_blank\">https://github.com/iamtraction/node-mcp-server</a><br>\n A TypeScript template repository for creating Model Context Protocol (MCP) servers with support for both stdio (Standard Input/Output) and SSE (Server-Sent Events) transports. This template provides a solid foundation for building MCP servers with a well-organized structure and essential features ...</p>\n<p><strong>GitHub - upstash/context7: Context7 MCP Server -- Up-to-date code...</strong><br>\n<a href=\"https://github.com/upstash/context7\" target=\"_blank\">https://github.com/upstash/context7</a><br>\nMar 25, 2025 Node.js >= v18.0.0. Cursor, Claude Code, VSCode, Windsurf or another MCP Client.Always use context7 when I need code generation, setup or configuration steps, or library/API documentation. This means you should automatically use the Context7 MCP tools to resolve library id and get library docs without me having to explicitly ask. From then on, you’ll get Context7’s docs in any related conversation without typing anything extra.</p>\n</details>\n<details><summary>Gathered key details from:<p></p>\n<ul>\n<li><a href=\"https://github.com/lucianoayres/mcp-server-node\" target=\"_blank\">mcp-server-node GitHub Repo</a></li></ul></summary>\n\n<h3>Query</h3>\n<p>MCP server example nodejs without modules</p>\n<h3>Response</h3>\n<h2>Installation</h2>\n<ol>\n<li><strong>Clone the Repository</strong></li>\n</ol>\n<div class=\"codehilite\"><span class=\"filename\">bash</span><pre><span></span><code>git clone <repository_url>\ncd <repository_directory>\n</code></pre></div>\n<ol start=\"2\">\n<li>\n<p><strong>Install Dependencies</strong></p>\n<p>You can install the project dependencies in one of two ways:</p>\n<p><strong>Option 1: Install using the existing <code>package.json</code></strong></p>\n<p>Simply run:</p>\n</li>\n</ol>\n<div class=\"codehilite\"><span class=\"filename\">bash</span><pre><span></span><code>npm install\n</code></pre></div>\n<p><strong>Option 2: Install dependencies manually</strong></p>\n<p>If you prefer, delete the existing <code>package.json</code> and install the required packages manually:</p>\n<div class=\"codehilite\"><span class=\"filename\">bash</span><pre><span></span><code>npm install @modelcontextprotocol/sdk zod\n</code></pre></div>\n<p>Then, update the newly generated <code>package.json</code> file to include the following lines, which enables ES Modules and adds the mcp inspector command:</p>\n<div class=\"codehilite\"><span class=\"filename\">json</span><pre><span></span><code>\"type\": \"module\",\n\"scripts\": {\n \"inspector\": \"npx @modelcontextprotocol/inspector node ./mcp-server.js\"\n}\n</code></pre></div>\n<hr>\n<h2>Code Overview</h2>\n<p>The project comprises the following key parts:</p>\n<ul>\n<li>\n<p><strong>MCP Server Initialization:</strong> <br>\nThe MCP server is instantiated using <code>McpServer</code> from the MCP SDK and connected via <code>StdioServerTransport</code>.</p>\n</li>\n<li>\n<p><strong>Tool Definitions:</strong></p>\n</li>\n<li>\n<p><strong>add:</strong> <br>\n Defined with a Zod schema that accepts two numbers (<code>a</code> and <code>b</code>) and returns their sum as text.</p>\n</li>\n<li>\n<p><strong>getApiKey:</strong> <br>\n Retrieves the API key from the environment variable <code>API_KEY</code> and returns it as text.</p>\n</li>\n<li>\n<p><strong>Prompt Definition:</strong></p>\n<ul>\n<li><strong>add_numbers:</strong> <br>\nA predefined prompt that allows AI models to infer the usage of the addition tool.</li>\n</ul>\n</li>\n</ul>\n<p><strong>Important Note</strong>: It's not required to have a prompt defined for a tool. This example just demonstrates one of the capabilities of prompts, allowing the AI model to infer which tool to use based on your input. The AI can also use tools directly when it determines they're needed for a task.</p>\n</details><div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"k\">const</span> <span class=\"n\">readline</span> <span class=\"o\">=</span> <span class=\"nb\">require</span><span class=\"p\">(</span><span class=\"s\">\"readline\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n<span class=\"c\">// Setup stdin/stdout communication</span>\n<span class=\"k\">const</span> <span class=\"n\">rl</span> <span class=\"o\">=</span> <span class=\"n\">readline</span><span class=\"p\">.</span><span class=\"nf\">createInterface</span><span class=\"p\">(</span><span class=\"p\">{</span>\n input: <span class=\"n\">process</span><span class=\"p\">.</span>stdin<span class=\"p\">,</span>\n output: <span class=\"n\">process</span><span class=\"p\">.</span>stdout<span class=\"p\">,</span>\n terminal: <span class=\"kc\">false</span>\n<span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n<span class=\"c\">// Handle incoming JSON-RPC messages</span>\n<span class=\"n\">rl</span><span class=\"p\">.</span><span class=\"nf\">on</span><span class=\"p\">(</span><span class=\"s\">\"line\"</span><span class=\"p\">,</span> <span class=\"p\">(</span><span class=\"n\">line</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">message</span> <span class=\"o\">=</span> <span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">parse</span><span class=\"p\">(</span><span class=\"n\">line</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Route to handler</span>\n <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>method <span class=\"o\">===</span> <span class=\"s\">\"initialize\"</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nf\">handleInitialize</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span> <span class=\"k\">else</span> <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>method <span class=\"o\">===</span> <span class=\"s\">\"tools/list\"</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nf\">handleToolsList</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span> <span class=\"k\">else</span> <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>method <span class=\"o\">===</span> <span class=\"s\">\"tools/call\"</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nf\">handleToolCall</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n<span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n<span class=\"k\">function</span> <span class=\"nf\">send</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">stringify</span><span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"p\">}</span>\n\n<span class=\"k\">function</span> <span class=\"nf\">handleInitialize</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nf\">send</span><span class=\"p\">(</span><span class=\"p\">{</span>\n jsonrpc: <span class=\"s\">\"2.0\"</span><span class=\"p\">,</span>\n id: <span class=\"n\">request</span><span class=\"p\">.</span>id<span class=\"p\">,</span>\n result: <span class=\"p\">{</span>\n protocolVersion: <span class=\"s\">\"2024-11-05\"</span><span class=\"p\">,</span>\n capabilities: <span class=\"p\">{</span>\n tools: <span class=\"p\">{</span><span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">,</span>\n serverInfo: <span class=\"p\">{</span>\n name: <span class=\"s\">\"simple-server\"</span><span class=\"p\">,</span>\n version: <span class=\"s\">\"1.0.0\"</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"p\">}</span>\n\n<span class=\"k\">function</span> <span class=\"nf\">handleToolsList</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nf\">send</span><span class=\"p\">(</span><span class=\"p\">{</span>\n jsonrpc: <span class=\"s\">\"2.0\"</span><span class=\"p\">,</span>\n id: <span class=\"n\">request</span><span class=\"p\">.</span>id<span class=\"p\">,</span>\n result: <span class=\"p\">{</span>\n tools: <span class=\"p\">[</span>\n <span class=\"p\">{</span>\n name: <span class=\"s\">\"add\"</span><span class=\"p\">,</span>\n description: <span class=\"s\">\"Add two numbers\"</span><span class=\"p\">,</span>\n inputSchema: <span class=\"p\">{</span>\n type: <span class=\"s\">\"object\"</span><span class=\"p\">,</span>\n properties: <span class=\"p\">{</span>\n a: <span class=\"p\">{</span> type: <span class=\"s\">\"number\"</span> <span class=\"p\">}</span><span class=\"p\">,</span>\n b: <span class=\"p\">{</span> type: <span class=\"s\">\"number\"</span> <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">,</span>\n required: <span class=\"p\">[</span><span class=\"s\">\"a\"</span><span class=\"p\">,</span> <span class=\"s\">\"b\"</span><span class=\"p\">]</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span>\n <span class=\"p\">]</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"p\">}</span>\n\n<span class=\"k\">function</span> <span class=\"nf\">handleToolCall</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"p\">{</span> name<span class=\"p\">,</span> arguments: <span class=\"n\">args</span> <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"n\">request</span><span class=\"p\">.</span>params<span class=\"p\">;</span>\n\n <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">name</span> <span class=\"o\">===</span> <span class=\"s\">\"add\"</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">result</span> <span class=\"o\">=</span> <span class=\"n\">args</span><span class=\"p\">.</span>a <span class=\"o\">+</span> <span class=\"n\">args</span><span class=\"p\">.</span>b<span class=\"p\">;</span>\n <span class=\"nf\">send</span><span class=\"p\">(</span><span class=\"p\">{</span>\n jsonrpc: <span class=\"s\">\"2.0\"</span><span class=\"p\">,</span>\n id: <span class=\"n\">request</span><span class=\"p\">.</span>id<span class=\"p\">,</span>\n result: <span class=\"p\">{</span>\n content: <span class=\"p\">[</span>\n <span class=\"p\">{</span>\n type: <span class=\"s\">\"text\"</span><span class=\"p\">,</span>\n text: <span class=\"s\">`Result: <span class=\"p\">${</span><span class=\"n\">result</span><span class=\"p\">}</span>`</span>\n <span class=\"p\">}</span>\n <span class=\"p\">]</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n<span class=\"p\">}</span>\n\n<span class=\"c\">// Keep process alive</span>\n<span class=\"n\">process</span><span class=\"p\">.</span>stdin<span class=\"p\">.</span><span class=\"nf\">resume</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n</code></pre></div>\n<p>Core mechanics: <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts#:~:text=Understanding%20the,enable%20server\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Understanding MCP clients</b></a><span class=\"passage\">Understanding the distinction is important: the host is the application users interact with, while clients are the protocol-level components that enable server ...</span></span></sup></p>\n<ul>\n<li><code>readline</code>: Parses newline-delimited JSON from stdin</li>\n<li><code>console.log()</code>: Sends JSON-RPC responses to stdout</li>\n<li>Three handlers: initialize, tools/list, tools/call</li>\n<li>Each response matches request ID</li>\n</ul>","md":"```javascript\nconst readline = require(\"readline\");\n\n// Setup stdin/stdout communication\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n terminal: false\n});\n\n// Handle incoming JSON-RPC messages\nrl.on(\"line\", (line) => {\n const message = JSON.parse(line);\n \n // Route to handler\n if (message.method === \"initialize\") {\n handleInitialize(message);\n } else if (message.method === \"tools/list\") {\n handleToolsList(message);\n } else if (message.method === \"tools/call\") {\n handleToolCall(message);\n }\n});\n\nfunction send(message) {\n console.log(JSON.stringify(message));\n}\n\nfunction handleInitialize(request) {\n send({\n jsonrpc: \"2.0\",\n id: request.id,\n result: {\n protocolVersion: \"2024-11-05\",\n capabilities: {\n tools: {}\n },\n serverInfo: {\n name: \"simple-server\",\n version: \"1.0.0\"\n }\n }\n });\n}\n\nfunction handleToolsList(request) {\n send({\n jsonrpc: \"2.0\",\n id: request.id,\n result: {\n tools: [\n {\n name: \"add\",\n description: \"Add two numbers\",\n inputSchema: {\n type: \"object\",\n properties: {\n a: { type: \"number\" },\n b: { type: \"number\" }\n },\n required: [\"a\", \"b\"]\n }\n }\n ]\n }\n });\n}\n\nfunction handleToolCall(request) {\n const { name, arguments: args } = request.params;\n \n if (name === \"add\") {\n const result = args.a + args.b;\n send({\n jsonrpc: \"2.0\",\n id: request.id,\n result: {\n content: [\n {\n type: \"text\",\n text: `Result: ${result}`\n }\n ]\n }\n });\n }\n}\n\n// Keep process alive\nprocess.stdin.resume();\n```\n\nCore mechanics: [^1]\n- `readline`: Parses newline-delimited JSON from stdin\n- `console.log()`: Sends JSON-RPC responses to stdout\n- Three handlers: initialize, tools/list, tools/call\n- Each response matches request ID","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">68</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">7,597</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.05 / 0.17</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">25.89</span>\n</li>\n\n","documents":[]},{"id":"2e8fdf52-a6fa-4b22-9536-557618d8775d","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:47:02Z","state":"done","prompt":"Now a llm as the host using it. Also as bare bones as possible","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>LLM as host barebones example MCP</li></ul></summary> Sources (3):<br>\n<strong>Tome: An open source local LLM client for tinkering with ...</strong><br>\n<a href=\"https://www.reddit.com/r/LocalLLM/comments/1kb2xrm/tome_an_open_source_local_llm_client_for/\" target=\"_blank\">https://www.reddit.com/r/LocalLLM/comments/1kb2xrm/tome_an_open_source_local_llm_client_for/</a><br>\nMay 03, 2025 A simple local LLM client on GH that lets you play with MCP servers without having to manage uv/npm or any json configs.\n\n<p><strong>GitHub - ALucek/quick-mcp-example: Short and sweet example MCP server ...</strong><br>\n<a href=\"https://github.com/ALucek/quick-mcp-example\" target=\"_blank\">https://github.com/ALucek/quick-mcp-example</a><br>\n Clients manage: Connections to servers, LLM integration, message passing between components Hosts provide: Frontend interfaces, surfacing of MCP functionality to users, integration points for the overall ecosystem This architecture creates a modular system where different components can be developed independently while maintaining interoperability.</p>\n<p><strong>How to Build Your Own MCP Server with Python - freeCodeCamp.org</strong><br>\n<a href=\"https://www.freecodecamp.org/news/how-to-build-your-own-mcp-server-with-python/\" target=\"_blank\">https://www.freecodecamp.org/news/how-to-build-your-own-mcp-server-with-python/</a><br>\n You will get a cloud url eg. https://python-mcp-server-rlfdk.sevalla.app. Use this as the base url instead of the localhost:3000 url. You now have a production-grade MCP server running on the cloud. You can plug this into any application to fetch data for our LLM applications. Why Build Your Own MCP Server?</p>\n</details><div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"c\">// host.js - LLM application using MCP client</span>\n<span class=\"k\">const</span> <span class=\"p\">{</span> spawn <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"nb\">require</span><span class=\"p\">(</span><span class=\"s\">\"child_process\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"k\">const</span> <span class=\"n\">readline</span> <span class=\"o\">=</span> <span class=\"nb\">require</span><span class=\"p\">(</span><span class=\"s\">\"readline\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n<span class=\"k\">class</span> <span class=\"nf\">LLMHost</span> <span class=\"p\">{</span>\n <span class=\"nf\">constructor</span><span class=\"p\">(</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>client <span class=\"o\">=</span> <span class=\"kc\">null</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>messageId <span class=\"o\">=</span> 0<span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests <span class=\"o\">=</span> <span class=\"k\">new</span> <span class=\"nf\">Map</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">start</span><span class=\"p\">(</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"c\">// Start MCP server</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>client <span class=\"o\">=</span> <span class=\"nf\">spawn</span><span class=\"p\">(</span><span class=\"s\">\"node\"</span><span class=\"p\">,</span> <span class=\"p\">[</span><span class=\"s\">\"server.js\"</span><span class=\"p\">]</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">const</span> <span class=\"n\">rl</span> <span class=\"o\">=</span> <span class=\"n\">readline</span><span class=\"p\">.</span><span class=\"nf\">createInterface</span><span class=\"p\">(</span><span class=\"p\">{</span>\n input: <span class=\"nb\">this</span><span class=\"p\">.</span>client<span class=\"p\">.</span>stdout<span class=\"p\">,</span>\n crlfDelay: <span class=\"nf\">Infinity</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"n\">rl</span><span class=\"p\">.</span><span class=\"nf\">on</span><span class=\"p\">(</span><span class=\"s\">\"line\"</span><span class=\"p\">,</span> <span class=\"p\">(</span><span class=\"n\">line</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">msg</span> <span class=\"o\">=</span> <span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">parse</span><span class=\"p\">(</span><span class=\"n\">line</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>id <span class=\"o\">&&</span> <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">has</span><span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"p\">{</span> resolve <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">get</span><span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">delete</span><span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"nf\">resolve</span><span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>result<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Initialize</span>\n <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"initialize\"</span><span class=\"p\">,</span> <span class=\"p\">{</span>\n protocolVersion: <span class=\"s\">\"2024-11-05\"</span><span class=\"p\">,</span>\n capabilities: <span class=\"p\">{</span><span class=\"p\">}</span><span class=\"p\">,</span>\n clientInfo: <span class=\"p\">{</span> name: <span class=\"s\">\"llm-host\"</span><span class=\"p\">,</span> version: <span class=\"s\">\"1.0.0\"</span> <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Get available tools</span>\n <span class=\"k\">const</span> <span class=\"p\">{</span> tools <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"tools/list\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">\"Available tools:\"</span><span class=\"p\">,</span> <span class=\"n\">tools</span><span class=\"p\">.</span><span class=\"nf\">map</span><span class=\"p\">(</span><span class=\"n\">t</span> <span class=\"o\">=></span> <span class=\"n\">t</span><span class=\"p\">.</span>name<span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Simulate LLM deciding to use tool</span>\n <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">processUserQuery</span><span class=\"p\">(</span><span class=\"s\">\"What is 5 + 3?\"</span><span class=\"p\">,</span> <span class=\"n\">tools</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">processUserQuery</span><span class=\"p\">(</span><span class=\"n\">query</span><span class=\"p\">,</span> <span class=\"n\">tools</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">`\\nUser: <span class=\"p\">${</span><span class=\"n\">query</span><span class=\"p\">}</span>`</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// LLM decides to use \"add\" tool</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">\"LLM: I'll use the add tool\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">const</span> <span class=\"n\">result</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"tools/call\"</span><span class=\"p\">,</span> <span class=\"p\">{</span>\n name: <span class=\"s\">\"add\"</span><span class=\"p\">,</span>\n arguments: <span class=\"p\">{</span> a: 5<span class=\"p\">,</span> b: 3 <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">`LLM: <span class=\"p\">${</span><span class=\"n\">result</span><span class=\"p\">.</span>content<span class=\"p\">[</span>0<span class=\"p\">]</span><span class=\"p\">.</span>text<span class=\"p\">}</span>`</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"n\">method</span><span class=\"p\">,</span> <span class=\"n\">params</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">id</span> <span class=\"o\">=</span> <span class=\"o\">++</span><span class=\"nb\">this</span><span class=\"p\">.</span>messageId<span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>client<span class=\"p\">.</span>stdin<span class=\"p\">.</span><span class=\"nf\">write</span><span class=\"p\">(</span><span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">stringify</span><span class=\"p\">(</span><span class=\"p\">{</span>\n jsonrpc: <span class=\"s\">\"2.0\"</span><span class=\"p\">,</span>\n id<span class=\"p\">,</span>\n method<span class=\"p\">,</span>\n params\n <span class=\"p\">}</span><span class=\"p\">)</span> <span class=\"o\">+</span> <span class=\"s\">\"\\n\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">return</span> <span class=\"k\">new</span> <span class=\"nf\">Promise</span><span class=\"p\">(</span><span class=\"p\">(</span><span class=\"n\">resolve</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">set</span><span class=\"p\">(</span><span class=\"n\">id</span><span class=\"p\">,</span> <span class=\"p\">{</span> resolve <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n<span class=\"p\">}</span>\n\n<span class=\"k\">new</span> <span class=\"nf\">LLMHost</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">.</span><span class=\"nf\">start</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n</code></pre></div>\n<p>Flow:</p>\n<ol>\n<li>Host spawns MCP client connection to server</li>\n<li>Host gets available tools</li>\n<li>User asks question</li>\n<li>LLM (simulated) decides which tool to call</li>\n<li>Host executes tool via MCP client</li>\n<li>Host formats response to user</li>\n</ol>\n<p>In real implementation, replace <code>processUserQuery()</code> with actual LLM API calls (OpenAI, Anthropic, etc.) that include tool definitions in the prompt.</p>","md":"```javascript\n// host.js - LLM application using MCP client\nconst { spawn } = require(\"child_process\");\nconst readline = require(\"readline\");\n\nclass LLMHost {\n constructor() {\n this.client = null;\n this.messageId = 0;\n this.pendingRequests = new Map();\n }\n\n async start() {\n // Start MCP server\n this.client = spawn(\"node\", [\"server.js\"]);\n \n const rl = readline.createInterface({\n input: this.client.stdout,\n crlfDelay: Infinity\n });\n\n rl.on(\"line\", (line) => {\n const msg = JSON.parse(line);\n if (msg.id && this.pendingRequests.has(msg.id)) {\n const { resolve } = this.pendingRequests.get(msg.id);\n this.pendingRequests.delete(msg.id);\n resolve(msg.result);\n }\n });\n\n // Initialize\n await this.request(\"initialize\", {\n protocolVersion: \"2024-11-05\",\n capabilities: {},\n clientInfo: { name: \"llm-host\", version: \"1.0.0\" }\n });\n\n // Get available tools\n const { tools } = await this.request(\"tools/list\");\n console.log(\"Available tools:\", tools.map(t => t.name));\n\n // Simulate LLM deciding to use tool\n await this.processUserQuery(\"What is 5 + 3?\", tools);\n }\n\n async processUserQuery(query, tools) {\n console.log(`\\nUser: ${query}`);\n \n // LLM decides to use \"add\" tool\n console.log(\"LLM: I'll use the add tool\");\n \n const result = await this.request(\"tools/call\", {\n name: \"add\",\n arguments: { a: 5, b: 3 }\n });\n\n console.log(`LLM: ${result.content[0].text}`);\n }\n\n async request(method, params) {\n const id = ++this.messageId;\n this.client.stdin.write(JSON.stringify({\n jsonrpc: \"2.0\",\n id,\n method,\n params\n }) + \"\\n\");\n\n return new Promise((resolve) => {\n this.pendingRequests.set(id, { resolve });\n });\n }\n}\n\nnew LLMHost().start();\n```\n\nFlow:\n1. Host spawns MCP client connection to server\n2. Host gets available tools\n3. User asks question\n4. LLM (simulated) decides which tool to call\n5. Host executes tool via MCP client\n6. Host formats response to user\n\nIn real implementation, replace `processUserQuery()` with actual LLM API calls (OpenAI, Anthropic, etc.) that include tool definitions in the prompt.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">63</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">8,138</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.03 / 0.20</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">15.06</span>\n</li>\n\n","documents":[]},{"id":"882baba2-b155-4736-bbc9-5db5db0e7546","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:48:34Z","state":"done","prompt":"Don’t be lazy I want the real implementation ","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://platform.openai.com/docs/guides/function-calling\" >Function calling - OpenAI API</a>\n <span class=\"__domain-name\">platform.openai.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 100%, transparent 100%)\">100%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Function calling - OpenAI API](https://platform.openai.com/docs/guides/function-calling) (100%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>OpenAI function calling example</li>\n<li>Anthropic tool use example</li></ul></summary> Sources (6):<br>\n<strong>Function calling - OpenAI API</strong><br>\n<a href=\"https://platform.openai.com/docs/guides/function-calling\" target=\"_blank\">https://platform.openai.com/docs/guides/function-calling</a><br>\nAug 07, 2025 Explore developer resources, tutorials, API docs, and dynamic examples to get the most out of OpenAI's platform.\n\n<p><strong>OpenAI Platform</strong><br>\n<a href=\"https://platform.openai.com/images/guides/function-calling\" target=\"_blank\">https://platform.openai.com/images/guides/function-calling</a><br>\n Explore resources, tutorials, API docs, and dynamic examples to get the most out of OpenAI's developer platform.</p>\n<p><strong>Assistants Function Calling - OpenAI API</strong><br>\n<a href=\"https://platform.openai.com/docs/assistants/tools/function-calling\" target=\"_blank\">https://platform.openai.com/docs/assistants/tools/function-calling</a><br>\n Explore developer resources, tutorials, API docs, and dynamic examples to get the most out of OpenAI's platform.</p>\n<p><strong>Writing effective tools for AI agents—using ...</strong><br>\n<a href=\"https://www.anthropic.com/engineering/writing-tools-for-agents\" target=\"_blank\">https://www.anthropic.com/engineering/writing-tools-for-agents</a><br>\nSep 11, 2025 Claude is an expert at analyzing transcripts and refactoring lots of tools all at once—for example, to ensure tool implementations and ...</p>\n<p><strong>Anthropic Academy: Claude API Development Guide</strong><br>\n<a href=\"https://www.anthropic.com/learn/build-with-claude\" target=\"_blank\">https://www.anthropic.com/learn/build-with-claude</a><br>\n Learn to build applications with Claude's API. Find detailed documentation, integration guides, code examples, and best practices for developing with our AI capabilities.</p>\n<p><strong>Claude can now use tools - Anthropic</strong><br>\n<a href=\"https://www.anthropic.com/news/tool-use-ga\" target=\"_blank\">https://www.anthropic.com/news/tool-use-ga</a><br>\nMay 30, 2024 Tool use, which enables Claude to interact with external tools and APIs, is now generally available across the entire Claude 3 model family on the Anthropic Messages API, Amazon Bedrock, and Google Cloud's Vertex AI.</p>\n</details><div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"c\">// host.js - LLM host with OpenAI integration</span>\n<span class=\"k\">const</span> <span class=\"p\">{</span> spawn <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"nb\">require</span><span class=\"p\">(</span><span class=\"s\">\"child_process\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"k\">const</span> <span class=\"n\">readline</span> <span class=\"o\">=</span> <span class=\"nb\">require</span><span class=\"p\">(</span><span class=\"s\">\"readline\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"k\">const</span> <span class=\"n\">https</span> <span class=\"o\">=</span> <span class=\"nb\">require</span><span class=\"p\">(</span><span class=\"s\">\"https\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n<span class=\"k\">class</span> <span class=\"nf\">LLMHost</span> <span class=\"p\">{</span>\n <span class=\"nf\">constructor</span><span class=\"p\">(</span><span class=\"n\">apiKey</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>apiKey <span class=\"o\">=</span> <span class=\"n\">apiKey</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>client <span class=\"o\">=</span> <span class=\"kc\">null</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>messageId <span class=\"o\">=</span> 0<span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests <span class=\"o\">=</span> <span class=\"k\">new</span> <span class=\"nf\">Map</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>tools <span class=\"o\">=</span> <span class=\"p\">[</span><span class=\"p\">]</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">start</span><span class=\"p\">(</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"c\">// Start MCP server</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>client <span class=\"o\">=</span> <span class=\"nf\">spawn</span><span class=\"p\">(</span><span class=\"s\">\"node\"</span><span class=\"p\">,</span> <span class=\"p\">[</span><span class=\"s\">\"server.js\"</span><span class=\"p\">]</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">const</span> <span class=\"n\">rl</span> <span class=\"o\">=</span> <span class=\"n\">readline</span><span class=\"p\">.</span><span class=\"nf\">createInterface</span><span class=\"p\">(</span><span class=\"p\">{</span>\n input: <span class=\"nb\">this</span><span class=\"p\">.</span>client<span class=\"p\">.</span>stdout<span class=\"p\">,</span>\n crlfDelay: <span class=\"nf\">Infinity</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"n\">rl</span><span class=\"p\">.</span><span class=\"nf\">on</span><span class=\"p\">(</span><span class=\"s\">\"line\"</span><span class=\"p\">,</span> <span class=\"p\">(</span><span class=\"n\">line</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">msg</span> <span class=\"o\">=</span> <span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">parse</span><span class=\"p\">(</span><span class=\"n\">line</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>id <span class=\"o\">&&</span> <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">has</span><span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"p\">{</span> resolve <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">get</span><span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">delete</span><span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>id<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"nf\">resolve</span><span class=\"p\">(</span><span class=\"n\">msg</span><span class=\"p\">.</span>result<span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Initialize MCP connection</span>\n <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">mcpRequest</span><span class=\"p\">(</span><span class=\"s\">\"initialize\"</span><span class=\"p\">,</span> <span class=\"p\">{</span>\n protocolVersion: <span class=\"s\">\"2024-11-05\"</span><span class=\"p\">,</span>\n capabilities: <span class=\"p\">{</span><span class=\"p\">}</span><span class=\"p\">,</span>\n clientInfo: <span class=\"p\">{</span> name: <span class=\"s\">\"llm-host\"</span><span class=\"p\">,</span> version: <span class=\"s\">\"1.0.0\"</span> <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Get available tools from MCP server</span>\n <span class=\"k\">const</span> <span class=\"p\">{</span> tools <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">mcpRequest</span><span class=\"p\">(</span><span class=\"s\">\"tools/list\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>tools <span class=\"o\">=</span> <span class=\"n\">tools</span><span class=\"p\">;</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">\"MCP tools loaded:\"</span><span class=\"p\">,</span> <span class=\"n\">tools</span><span class=\"p\">.</span><span class=\"nf\">map</span><span class=\"p\">(</span><span class=\"n\">t</span> <span class=\"o\">=></span> <span class=\"n\">t</span><span class=\"p\">.</span>name<span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Process user query</span>\n <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">processUserQuery</span><span class=\"p\">(</span><span class=\"s\">\"What is 15 + 27?\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">processUserQuery</span><span class=\"p\">(</span><span class=\"n\">query</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">`\\nUser: <span class=\"p\">${</span><span class=\"n\">query</span><span class=\"p\">}</span>`</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Convert MCP tools to OpenAI function format</span>\n <span class=\"k\">const</span> <span class=\"n\">functions</span> <span class=\"o\">=</span> <span class=\"nb\">this</span><span class=\"p\">.</span>tools<span class=\"p\">.</span><span class=\"nf\">map</span><span class=\"p\">(</span><span class=\"n\">t</span> <span class=\"o\">=></span> <span class=\"p\">(</span><span class=\"p\">{</span>\n name: <span class=\"n\">t</span><span class=\"p\">.</span>name<span class=\"p\">,</span>\n description: <span class=\"n\">t</span><span class=\"p\">.</span>description<span class=\"p\">,</span>\n parameters: <span class=\"n\">t</span><span class=\"p\">.</span>inputSchema\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Call OpenAI with function calling</span>\n <span class=\"k\">const</span> <span class=\"n\">completion</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">callOpenAI</span><span class=\"p\">(</span><span class=\"p\">[</span>\n <span class=\"p\">{</span> role: <span class=\"s\">\"user\"</span><span class=\"p\">,</span> content: <span class=\"n\">query</span> <span class=\"p\">}</span>\n <span class=\"p\">]</span><span class=\"p\">,</span> <span class=\"n\">functions</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">const</span> <span class=\"n\">message</span> <span class=\"o\">=</span> <span class=\"n\">completion</span><span class=\"p\">.</span>choices<span class=\"p\">[</span>0<span class=\"p\">]</span><span class=\"p\">.</span>message<span class=\"p\">;</span>\n\n <span class=\"c\">// Check if LLM wants to call a function</span>\n <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">message</span><span class=\"p\">.</span>function_call<span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"p\">{</span> name<span class=\"p\">,</span> arguments: <span class=\"n\">argsStr</span> <span class=\"p\">}</span> <span class=\"o\">=</span> <span class=\"n\">message</span><span class=\"p\">.</span>function_call<span class=\"p\">;</span>\n <span class=\"k\">const</span> <span class=\"n\">args</span> <span class=\"o\">=</span> <span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">parse</span><span class=\"p\">(</span><span class=\"n\">argsStr</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">`LLM calling tool: <span class=\"p\">${</span><span class=\"n\">name</span><span class=\"p\">}</span>(<span class=\"p\">${</span><span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">stringify</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"p\">)</span><span class=\"p\">}</span>)`</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Execute tool via MCP</span>\n <span class=\"k\">const</span> <span class=\"n\">result</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">mcpRequest</span><span class=\"p\">(</span><span class=\"s\">\"tools/call\"</span><span class=\"p\">,</span> <span class=\"p\">{</span>\n name<span class=\"p\">,</span>\n arguments: <span class=\"n\">args</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"c\">// Send result back to LLM for final response</span>\n <span class=\"k\">const</span> <span class=\"n\">finalCompletion</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">callOpenAI</span><span class=\"p\">(</span><span class=\"p\">[</span>\n <span class=\"p\">{</span> role: <span class=\"s\">\"user\"</span><span class=\"p\">,</span> content: <span class=\"n\">query</span> <span class=\"p\">}</span><span class=\"p\">,</span>\n <span class=\"n\">message</span><span class=\"p\">,</span>\n <span class=\"p\">{</span>\n role: <span class=\"s\">\"function\"</span><span class=\"p\">,</span>\n name<span class=\"p\">,</span>\n content: <span class=\"n\">result</span><span class=\"p\">.</span>content<span class=\"p\">[</span>0<span class=\"p\">]</span><span class=\"p\">.</span>text\n <span class=\"p\">}</span>\n <span class=\"p\">]</span><span class=\"p\">,</span> <span class=\"n\">functions</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">`Assistant: <span class=\"p\">${</span><span class=\"n\">finalCompletion</span><span class=\"p\">.</span>choices<span class=\"p\">[</span>0<span class=\"p\">]</span><span class=\"p\">.</span>message<span class=\"p\">.</span>content<span class=\"p\">}</span>`</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span> <span class=\"k\">else</span> <span class=\"p\">{</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">log</span><span class=\"p\">(</span><span class=\"s\">`Assistant: <span class=\"p\">${</span><span class=\"n\">message</span><span class=\"p\">.</span>content<span class=\"p\">}</span>`</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">callOpenAI</span><span class=\"p\">(</span><span class=\"n\">messages</span><span class=\"p\">,</span> <span class=\"n\">functions</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">data</span> <span class=\"o\">=</span> <span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">stringify</span><span class=\"p\">(</span><span class=\"p\">{</span>\n model: <span class=\"s\">\"gpt-4\"</span><span class=\"p\">,</span>\n messages<span class=\"p\">,</span>\n functions<span class=\"p\">,</span>\n function_call: <span class=\"s\">\"auto\"</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">return</span> <span class=\"k\">new</span> <span class=\"nf\">Promise</span><span class=\"p\">(</span><span class=\"p\">(</span><span class=\"n\">resolve</span><span class=\"p\">,</span> <span class=\"n\">reject</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">req</span> <span class=\"o\">=</span> <span class=\"n\">https</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"p\">{</span>\n hostname: <span class=\"s\">\"api.openai.com\"</span><span class=\"p\">,</span>\n path: <span class=\"s\">\"/v1/chat/completions\"</span><span class=\"p\">,</span>\n method: <span class=\"s\">\"POST\"</span><span class=\"p\">,</span>\n headers: <span class=\"p\">{</span>\n <span class=\"s\">\"Content-Type\"</span>: <span class=\"s\">\"application/json\"</span><span class=\"p\">,</span>\n <span class=\"s\">\"Authorization\"</span>: <span class=\"s\">`Bearer <span class=\"p\">${</span><span class=\"nb\">this</span><span class=\"p\">.</span>apiKey<span class=\"p\">}</span>`</span><span class=\"p\">,</span>\n <span class=\"s\">\"Content-Length\"</span>: <span class=\"n\">data</span><span class=\"p\">.</span>length\n <span class=\"p\">}</span>\n <span class=\"p\">}</span><span class=\"p\">,</span> <span class=\"p\">(</span><span class=\"n\">res</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"k\">let</span> <span class=\"n\">body</span> <span class=\"o\">=</span> <span class=\"s\">\"\"</span><span class=\"p\">;</span>\n <span class=\"n\">res</span><span class=\"p\">.</span><span class=\"nf\">on</span><span class=\"p\">(</span><span class=\"s\">\"data\"</span><span class=\"p\">,</span> <span class=\"n\">chunk</span> <span class=\"o\">=></span> <span class=\"n\">body</span> <span class=\"o\">+=</span> <span class=\"n\">chunk</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"n\">res</span><span class=\"p\">.</span><span class=\"nf\">on</span><span class=\"p\">(</span><span class=\"s\">\"end\"</span><span class=\"p\">,</span> <span class=\"p\">(</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"n\">resolve</span><span class=\"p\">(</span><span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">parse</span><span class=\"p\">(</span><span class=\"n\">body</span><span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"n\">req</span><span class=\"p\">.</span><span class=\"nf\">on</span><span class=\"p\">(</span><span class=\"s\">\"error\"</span><span class=\"p\">,</span> <span class=\"n\">reject</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"n\">req</span><span class=\"p\">.</span><span class=\"nf\">write</span><span class=\"p\">(</span><span class=\"n\">data</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"n\">req</span><span class=\"p\">.</span><span class=\"nf\">end</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">async</span> <span class=\"nf\">mcpRequest</span><span class=\"p\">(</span><span class=\"n\">method</span><span class=\"p\">,</span> <span class=\"n\">params</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">const</span> <span class=\"n\">id</span> <span class=\"o\">=</span> <span class=\"o\">++</span><span class=\"nb\">this</span><span class=\"p\">.</span>messageId<span class=\"p\">;</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>client<span class=\"p\">.</span>stdin<span class=\"p\">.</span><span class=\"nf\">write</span><span class=\"p\">(</span><span class=\"no\">JSON</span><span class=\"p\">.</span><span class=\"nf\">stringify</span><span class=\"p\">(</span><span class=\"p\">{</span>\n jsonrpc: <span class=\"s\">\"2.0\"</span><span class=\"p\">,</span>\n id<span class=\"p\">,</span>\n method<span class=\"p\">,</span>\n params\n <span class=\"p\">}</span><span class=\"p\">)</span> <span class=\"o\">+</span> <span class=\"s\">\"\\n\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n\n <span class=\"k\">return</span> <span class=\"k\">new</span> <span class=\"nf\">Promise</span><span class=\"p\">(</span><span class=\"p\">(</span><span class=\"n\">resolve</span><span class=\"p\">)</span> <span class=\"o\">=></span> <span class=\"p\">{</span>\n <span class=\"nb\">this</span><span class=\"p\">.</span>pendingRequests<span class=\"p\">.</span><span class=\"nf\">set</span><span class=\"p\">(</span><span class=\"n\">id</span><span class=\"p\">,</span> <span class=\"p\">{</span> resolve <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n<span class=\"p\">}</span>\n\n<span class=\"c\">// Usage: node host.js</span>\n<span class=\"k\">const</span> <span class=\"n\">apiKey</span> <span class=\"o\">=</span> <span class=\"n\">process</span><span class=\"p\">.</span>env<span class=\"p\">.</span>OPENAI_API_KEY<span class=\"p\">;</span>\n<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">apiKey</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"nb\">console</span><span class=\"p\">.</span><span class=\"nf\">error</span><span class=\"p\">(</span><span class=\"s\">\"Set OPENAI_API_KEY environment variable\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"n\">process</span><span class=\"p\">.</span><span class=\"nf\">exit</span><span class=\"p\">(</span>1<span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"p\">}</span>\n\n<span class=\"k\">new</span> <span class=\"nf\">LLMHost</span><span class=\"p\">(</span><span class=\"n\">apiKey</span><span class=\"p\">)</span><span class=\"p\">.</span><span class=\"nf\">start</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n</code></pre></div>\n<p>Flow: <sup class=\"trigger\"><a href=\"https://platform.openai.com/docs/guides/function-calling\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://platform.openai.com/docs/guides/function-calling#:~:text=Explore%20developer,OpenAI%27s%20platform.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJPsY98fIE49yieLfH1g0J3WIo50sgAGrzx-CUx7DwLNIP9YCBClUgMt2Ft9435p27\"> platform.openai.com</span><b>1. Function calling - OpenAI API</b></a><span class=\"passage\">Explore developer resources, tutorials, API docs, and dynamic examples to get the most out of OpenAI's platform.</span></span></sup></p>\n<ol>\n<li>Host spawns MCP server, gets available tools</li>\n<li>Converts MCP tool schemas to OpenAI function format</li>\n<li>Sends user query + functions to OpenAI</li>\n<li>OpenAI returns function call decision</li>\n<li>Host executes tool via MCP</li>\n<li>Host sends result back to OpenAI for natural language response</li>\n</ol>\n<p>Run: <code>OPENAI_API_KEY=your_key node host.js</code></p>","md":"```javascript\n// host.js - LLM host with OpenAI integration\nconst { spawn } = require(\"child_process\");\nconst readline = require(\"readline\");\nconst https = require(\"https\");\n\nclass LLMHost {\n constructor(apiKey) {\n this.apiKey = apiKey;\n this.client = null;\n this.messageId = 0;\n this.pendingRequests = new Map();\n this.tools = [];\n }\n\n async start() {\n // Start MCP server\n this.client = spawn(\"node\", [\"server.js\"]);\n \n const rl = readline.createInterface({\n input: this.client.stdout,\n crlfDelay: Infinity\n });\n\n rl.on(\"line\", (line) => {\n const msg = JSON.parse(line);\n if (msg.id && this.pendingRequests.has(msg.id)) {\n const { resolve } = this.pendingRequests.get(msg.id);\n this.pendingRequests.delete(msg.id);\n resolve(msg.result);\n }\n });\n\n // Initialize MCP connection\n await this.mcpRequest(\"initialize\", {\n protocolVersion: \"2024-11-05\",\n capabilities: {},\n clientInfo: { name: \"llm-host\", version: \"1.0.0\" }\n });\n\n // Get available tools from MCP server\n const { tools } = await this.mcpRequest(\"tools/list\");\n this.tools = tools;\n console.log(\"MCP tools loaded:\", tools.map(t => t.name));\n\n // Process user query\n await this.processUserQuery(\"What is 15 + 27?\");\n }\n\n async processUserQuery(query) {\n console.log(`\\nUser: ${query}`);\n \n // Convert MCP tools to OpenAI function format\n const functions = this.tools.map(t => ({\n name: t.name,\n description: t.description,\n parameters: t.inputSchema\n }));\n\n // Call OpenAI with function calling\n const completion = await this.callOpenAI([\n { role: \"user\", content: query }\n ], functions);\n\n const message = completion.choices[0].message;\n\n // Check if LLM wants to call a function\n if (message.function_call) {\n const { name, arguments: argsStr } = message.function_call;\n const args = JSON.parse(argsStr);\n \n console.log(`LLM calling tool: ${name}(${JSON.stringify(args)})`);\n\n // Execute tool via MCP\n const result = await this.mcpRequest(\"tools/call\", {\n name,\n arguments: args\n });\n\n // Send result back to LLM for final response\n const finalCompletion = await this.callOpenAI([\n { role: \"user\", content: query },\n message,\n {\n role: \"function\",\n name,\n content: result.content[0].text\n }\n ], functions);\n\n console.log(`Assistant: ${finalCompletion.choices[0].message.content}`);\n } else {\n console.log(`Assistant: ${message.content}`);\n }\n }\n\n async callOpenAI(messages, functions) {\n const data = JSON.stringify({\n model: \"gpt-4\",\n messages,\n functions,\n function_call: \"auto\"\n });\n\n return new Promise((resolve, reject) => {\n const req = https.request({\n hostname: \"api.openai.com\",\n path: \"/v1/chat/completions\",\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"Authorization\": `Bearer ${this.apiKey}`,\n \"Content-Length\": data.length\n }\n }, (res) => {\n let body = \"\";\n res.on(\"data\", chunk => body += chunk);\n res.on(\"end\", () => resolve(JSON.parse(body)));\n });\n\n req.on(\"error\", reject);\n req.write(data);\n req.end();\n });\n }\n\n async mcpRequest(method, params) {\n const id = ++this.messageId;\n this.client.stdin.write(JSON.stringify({\n jsonrpc: \"2.0\",\n id,\n method,\n params\n }) + \"\\n\");\n\n return new Promise((resolve) => {\n this.pendingRequests.set(id, { resolve });\n });\n }\n}\n\n// Usage: node host.js\nconst apiKey = process.env.OPENAI_API_KEY;\nif (!apiKey) {\n console.error(\"Set OPENAI_API_KEY environment variable\");\n process.exit(1);\n}\n\nnew LLMHost(apiKey).start();\n```\n\nFlow: [^1]\n1. Host spawns MCP server, gets available tools\n2. Converts MCP tool schemas to OpenAI function format\n3. Sends user query + functions to OpenAI\n4. OpenAI returns function call decision\n5. Host executes tool via MCP\n6. Host sends result back to OpenAI for natural language response\n\nRun: `OPENAI_API_KEY=your_key node host.js`","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">76</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">10,238</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.04 / 0.24</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">22.1</span>\n</li>\n\n","documents":[]},{"id":"db04a4b7-3096-4eb1-b8ee-2eeea27889f9","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:50:28Z","state":"done","prompt":"So this is actually don’t Ma convention on top of Tool calling ","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/docs/getting-started/intro\" >What is the Model Context Protocol (MCP)?</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 68%, transparent 68%)\">68%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" >Build an MCP client - Model Context Protocol</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 23%, transparent 23%)\">23%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/specification/2025-06-18/server/tools\" >Tools</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 9%, transparent 9%)\">9%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [What is the Model Context Protocol (MCP)?](https://modelcontextprotocol.io/docs/getting-started/intro) (68%)\n[^2]: [Build an MCP client - Model Context Protocol](https://modelcontextprotocol.io/docs/develop/build-client) (23%)\n[^3]: [Tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools) (9%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Model Context Protocol tool calling</li></ul></summary> Sources (3):<br>\n<strong>Tools</strong><br>\n<a href=\"https://modelcontextprotocol.io/specification/2025-06-18/server/tools\" target=\"_blank\">https://modelcontextprotocol.io/specification/2025-06-18/server/tools</a><br>\nJun 18, 2025 Tools enable models to interact with external systems, such as ... Calling Tools. To invoke a tool, clients send a tools/call request: ...\n\n<p><strong>Build an MCP client - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" target=\"_blank\">https://modelcontextprotocol.io/docs/develop/build-client</a><br>\nDec 11, 2024 \"input_schema\": tool.inputSchema } for tool in response.tools] #. Initial Claude API call response = self.anthropic.messages.create(. model=\"claude-3-5-sonnet-20241022\", max_tokens=1000Maintains conversation context. Handles Claude’s responses and tool calls. Manages the message flow between Claude and tools. Combines results into a coherent response.</p>\n<p><strong>What is the Model Context Protocol (MCP)?</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/getting-started/intro\" target=\"_blank\">https://modelcontextprotocol.io/docs/getting-started/intro</a><br>\n MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems. Using MCP, AI applications like Claude or ChatGPT can connect to data sources (e.g. local files, databases), tools (e.g. search engines, calculators) and workflows (e.g. specialized prompts)—enabling them to access key information and perform tasks. Think of MCP like a USB-C port for ...</p>\n</details><p>Yes, exactly. MCP is a standardized protocol layer on top of tool calling. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-06-18/server/tools\" target=\"_blank\">3</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-06-18/server/tools#:~:text=Tools%20enable,such%20as&text=Calling%20Tools.,tools/call%20request%3A\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>3. Tools</b></a><span class=\"passage\">Tools enable models to interact with external systems, such as ... Calling Tools. To invoke a tool, clients send a tools/call request: ...</span></span></sup><sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/docs/develop/build-client\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/docs/develop/build-client#:~:text=%22input_schema%22%3A%20tool.inputSchema,coherent%20response.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>2. Build an MCP client - Model Context Protocol</b></a><span class=\"passage\">\"input_schema\": tool.inputSchema } for tool in response.tools] #. Initial Claude API call response = self.anthropic.messages.create(. model=\"claude-3-5-sonnet-20241022\", max_tokens=1000Maintains conversation context. Handles Claude’s responses and tool calls. Manages the message flow between Claude and tools. Combines results into a coherent response.</span></span></sup></p>\n<p><strong>The relationship:</strong></p>\n<ul>\n<li><strong>Tool calling</strong>: LLM capability to decide when/how to use functions (OpenAI, Anthropic, etc. all have this)</li>\n<li><strong>MCP</strong>: Standardized protocol for <em>exposing</em> and <em>invoking</em> those tools</li>\n</ul>\n<p><strong>What MCP adds:</strong></p>\n<ol>\n<li><strong>Discovery</strong>: Standard way to list available tools (<code>tools/list</code>)</li>\n<li><strong>Invocation</strong>: Standard way to call tools (<code>tools/call</code>)</li>\n<li><strong>Schema format</strong>: Consistent tool definition structure (JSON Schema)</li>\n<li><strong>Transport</strong>: Standard communication layer (JSON-RPC over stdio/SSE)</li>\n</ol>\n<p><strong>Without MCP</strong>, each integration is custom:</p>\n<div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"c\">// Custom database integration</span>\n<span class=\"k\">const</span> <span class=\"n\">dbTools</span> <span class=\"o\">=</span> <span class=\"nf\">getDbTools</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"c\">// Custom API integration </span>\n<span class=\"k\">const</span> <span class=\"n\">apiTools</span> <span class=\"o\">=</span> <span class=\"nf\">getApiTools</span><span class=\"p\">(</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"c\">// Different schemas, different invocation methods</span>\n</code></pre></div>\n<p><strong>With MCP</strong>, everything is uniform:</p>\n<div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"c\">// All tools exposed via same protocol</span>\n<span class=\"k\">const</span> <span class=\"n\">tools1</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"n\">client1</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"tools/list\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"k\">const</span> <span class=\"n\">tools2</span> <span class=\"o\">=</span> <span class=\"k\">await</span> <span class=\"n\">client2</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"tools/list\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n<span class=\"c\">// Same invocation pattern</span>\n<span class=\"k\">await</span> <span class=\"n\">client1</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"tools/call\"</span><span class=\"p\">,</span> <span class=\"p\">{</span>...<span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n</code></pre></div>\n<p>The LLM still makes tool-calling decisions using its native function-calling capability. MCP just standardizes how those tools are discovered and executed. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/docs/getting-started/intro\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/docs/getting-started/intro#:~:text=MCP%20%28Model,port%20for\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. What is the Model Context Protocol (MCP)?</b></a><span class=\"passage\">MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems. Using MCP, AI applications like Claude or ChatGPT can connect to data sources (e.g. local files, databases), tools (e.g. search engines, calculators) and workflows (e.g. specialized prompts)—enabling them to access key information and perform tasks. Think of MCP like a USB-C port for ...</span></span></sup></p>\n<p>Think: USB-C for AI tools instead of proprietary connectors.</p>","md":"Yes, exactly. MCP is a standardized protocol layer on top of tool calling. [^3][^2]\n\n**The relationship:**\n\n- **Tool calling**: LLM capability to decide when/how to use functions (OpenAI, Anthropic, etc. all have this)\n- **MCP**: Standardized protocol for *exposing* and *invoking* those tools\n\n**What MCP adds:**\n\n1. **Discovery**: Standard way to list available tools (`tools/list`)\n2. **Invocation**: Standard way to call tools (`tools/call`)\n3. **Schema format**: Consistent tool definition structure (JSON Schema)\n4. **Transport**: Standard communication layer (JSON-RPC over stdio/SSE)\n\n**Without MCP**, each integration is custom:\n```javascript\n// Custom database integration\nconst dbTools = getDbTools();\n// Custom API integration \nconst apiTools = getApiTools();\n// Different schemas, different invocation methods\n```\n\n**With MCP**, everything is uniform:\n```javascript\n// All tools exposed via same protocol\nconst tools1 = await client1.request(\"tools/list\");\nconst tools2 = await client2.request(\"tools/list\");\n// Same invocation pattern\nawait client1.request(\"tools/call\", {...});\n```\n\nThe LLM still makes tool-calling decisions using its native function-calling capability. MCP just standardizes how those tools are discovered and executed. [^1]\n\nThink: USB-C for AI tools instead of proprietary connectors.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">32</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">8,407</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.02 / 0.27</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">16.99</span>\n</li>\n\n","documents":[]},{"id":"692c95de-4e5d-4351-95ec-7c17db90849e","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:53:43Z","state":"done","prompt":"So what is Anthropic skills in comparison?","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills\" >Equipping agents for the real world with Agent Skills \\ Anthropic</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 41%, transparent 41%)\">41%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.anthropic.com/news/skills\" >Claude Skills: Customize AI for your workflows</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 33%, transparent 33%)\">33%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.anthropic.com/engineering/writing-tools-for-agents\" >Writing effective tools for AI agents—using ...</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 17%, transparent 17%)\">17%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.anthropic.com/news/tool-use-ga\" >Claude can now use tools - Anthropic</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 9%, transparent 9%)\">9%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Equipping agents for the real world with Agent Skills \\ Anthropic](https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills) (41%)\n[^2]: [Claude Skills: Customize AI for your workflows](https://www.anthropic.com/news/skills) (33%)\n[^3]: [Writing effective tools for AI agents—using ...](https://www.anthropic.com/engineering/writing-tools-for-agents) (17%)\n[^4]: [Claude can now use tools - Anthropic](https://www.anthropic.com/news/tool-use-ga) (9%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Anthropic skills vs OpenAI functions</li>\n<li>Anthropic tools</li>\n<li>Anthropic skills</li></ul></summary> Sources (9):<br>\n<strong>Anthropic vs. OpenAI: What's the Difference?</strong><br>\n<a href=\"https://www.coursera.org/articles/anthropic-vs-openai\" target=\"_blank\">https://www.coursera.org/articles/anthropic-vs-openai</a><br>\nFeb 06, 2025 Anthropic strongly emphasizes ethical AI and helpful generative conversational AI. In contrast, OpenAI offers a broadly accessible suite of ...\n\n<p><strong>OpenAI API vs Anthropic API: The 2025 developer's guide</strong><br>\n<a href=\"https://www.eesel.ai/blog/openai-api-vs-anthropic-api\" target=\"_blank\">https://www.eesel.ai/blog/openai-api-vs-anthropic-api</a><br>\n A deep dive into the OpenAI API vs Anthropic API debate for 2025. Compare features, pricing, developer experience, and find out which is best for you.</p>\n<p><strong>OpenAI API vs Anthropic API vs Gemini API: A practical guide for ...</strong><br>\n<a href=\"https://www.eesel.ai/blog/openai-api-vs-anthropic-api-vs-gemini-api\" target=\"_blank\">https://www.eesel.ai/blog/openai-api-vs-anthropic-api-vs-gemini-api</a><br>\n A practical guide comparing the OpenAI API vs Anthropic API vs Gemini API for businesses in 2025. We break down performance, pricing, and implementation to help you choose.</p>\n<p><strong>Writing effective tools for AI agents—using ...</strong><br>\n<a href=\"https://www.anthropic.com/engineering/writing-tools-for-agents\" target=\"_blank\">https://www.anthropic.com/engineering/writing-tools-for-agents</a><br>\nSep 11, 2025 Start by standing up a quick prototype of your tools and testing them locally. Next, run a comprehensive evaluation to measure subsequent ...</p>\n<p><strong>Claude can now use tools - Anthropic</strong><br>\n<a href=\"https://www.anthropic.com/news/tool-use-ga\" target=\"_blank\">https://www.anthropic.com/news/tool-use-ga</a><br>\nMay 30, 2024 Tool use, which enables Claude to interact with external tools and APIs, is now generally available across the entire Claude 3 model family ...</p>\n<p><strong>Discover tools that work with Claude - anthropic.com</strong><br>\n<a href=\"https://www.anthropic.com/news/connectors-directory\" target=\"_blank\">https://www.anthropic.com/news/connectors-directory</a><br>\nJul 14, 2025 Today, we are introducing a new directory of tools that connect to Claude, which you can explore and try with a single click.</p>\n<p><strong>Claude Skills: Customize AI for your workflows</strong><br>\n<a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">https://www.anthropic.com/news/skills</a><br>\nOct 16, 2025 Build custom Skills to teach Claude specialized tasks. Create once, use everywhere—from spreadsheets to coding. Available across Claude.ai, ...</p>\n<p><strong>Equipping agents for the real world with Agent Skills \\ Anthropic</strong><br>\n<a href=\"https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills\" target=\"_blank\">https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills</a><br>\nOct 16, 2025 Discover how Anthropic builds AI agents with practical capabilities through modular skills, enabling them to handle complex real-world tasks ...</p>\n<p><strong>anthropics/skills: Public repository for Skills</strong><br>\n<a href=\"https://github.com/anthropics/skills\" target=\"_blank\">https://github.com/anthropics/skills</a><br>\nOct 16, 2025 Skills are folders of instructions, scripts, and resources that Claude loads dynamically to improve performance on specialized tasks. Skills teach Claude ...</p>\n</details><p><strong>Anthropic Skills</strong> are a higher-level abstraction than both tool calling and MCP. <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/skills#:~:text=Build%20custom,across%20Claude.ai%2C\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>2. Claude Skills: Customize AI for your workflows</b></a><span class=\"passage\">Build custom Skills to teach Claude specialized tasks. Create once, use everywhere—from spreadsheets to coding. Available across Claude.ai, ...</span></span></sup><sup class=\"trigger\"><a href=\"https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills#:~:text=Discover%20how,real-world%20tasks\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Equipping agents for the real world with Agent Skills \\ Anthropic</b></a><span class=\"passage\">Discover how Anthropic builds AI agents with practical capabilities through modular skills, enabling them to handle complex real-world tasks ...</span></span></sup></p>\n<h2>The hierarchy:</h2>\n<p><strong>Tool calling</strong> (lowest level): LLM capability to invoke functions</p>\n<ul>\n<li>OpenAI: function calling</li>\n<li>Anthropic: tool use <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/tool-use-ga\" target=\"_blank\">4</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/tool-use-ga#:~:text=Tool%20use%2C,model%20family\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>4. Claude can now use tools - Anthropic</b></a><span class=\"passage\">Tool use, which enables Claude to interact with external tools and APIs, is now generally available across the entire Claude 3 model family ...</span></span></sup></li>\n</ul>\n<p><strong>MCP</strong> (protocol level): Standardized interface for tool discovery/invocation</p>\n<ul>\n<li>Transport and schema conventions</li>\n<li>Works with any LLM that supports tool calling</li>\n</ul>\n<p><strong>Anthropic Skills</strong> (application level): Pre-packaged, reusable task modules <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/skills#:~:text=Build%20custom,across%20Claude.ai%2C\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>2. Claude Skills: Customize AI for your workflows</b></a><span class=\"passage\">Build custom Skills to teach Claude specialized tasks. Create once, use everywhere—from spreadsheets to coding. Available across Claude.ai, ...</span></span></sup><sup class=\"trigger\"><a href=\"https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/engineering/equipping-agents-for-the-real-world-with-agent-skills#:~:text=Discover%20how,real-world%20tasks\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Equipping agents for the real world with Agent Skills \\ Anthropic</b></a><span class=\"passage\">Discover how Anthropic builds AI agents with practical capabilities through modular skills, enabling them to handle complex real-world tasks ...</span></span></sup></p>\n<ul>\n<li>Combine instructions + tools + resources</li>\n<li>Teach Claude specialized workflows</li>\n<li>Portable across Claude.ai, API, desktop</li>\n</ul>\n<h2>Key differences:</h2>\n<p><strong>MCP</strong>: Protocol for <em>how</em> tools are exposed and called</p>\n<div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"c\">// Generic tool interface</span>\n<span class=\"k\">await</span> <span class=\"n\">client</span><span class=\"p\">.</span><span class=\"nf\">request</span><span class=\"p\">(</span><span class=\"s\">\"tools/call\"</span><span class=\"p\">,</span> <span class=\"p\">{</span> name: <span class=\"s\">\"add\"</span><span class=\"p\">,</span> arguments: <span class=\"p\">{</span>...<span class=\"p\">}</span> <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n</code></pre></div>\n<p><strong>Skills</strong>: Pre-configured <em>what</em> Claude should do</p>\n<div class=\"codehilite\"><span class=\"filename\">Plaintext</span><pre><span></span><code>Skill: \"Data Analysis\"\n- Instructions: \"Analyze CSV files...\"\n- Tools: [read_file, calculate_stats, create_chart]\n- Resources: [example_data.csv, templates/]\n</code></pre></div>\n<p><strong>Relationship:</strong></p>\n<ul>\n<li>Skills can <em>use</em> MCP servers as their tool backend</li>\n<li>MCP provides the plumbing, Skills provide the task definition</li>\n<li>Skills = instructions + MCP tools + context</li>\n</ul>\n<p>Skills are Anthropic-specific; MCP is vendor-neutral. <sup class=\"trigger\"><a href=\"https://www.anthropic.com/engineering/writing-tools-for-agents\" target=\"_blank\">3</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/engineering/writing-tools-for-agents#:~:text=Start%20by,measure%20subsequent\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>3. Writing effective tools for AI agents—using ...</b></a><span class=\"passage\">Start by standing up a quick prototype of your tools and testing them locally. Next, run a comprehensive evaluation to measure subsequent ...</span></span></sup><sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/skills#:~:text=Build%20custom,across%20Claude.ai%2C\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>2. Claude Skills: Customize AI for your workflows</b></a><span class=\"passage\">Build custom Skills to teach Claude specialized tasks. Create once, use everywhere—from spreadsheets to coding. Available across Claude.ai, ...</span></span></sup></p>","md":"**Anthropic Skills** are a higher-level abstraction than both tool calling and MCP. [^2][^1]\n\n## The hierarchy:\n\n**Tool calling** (lowest level): LLM capability to invoke functions\n- OpenAI: function calling\n- Anthropic: tool use [^4]\n\n**MCP** (protocol level): Standardized interface for tool discovery/invocation\n- Transport and schema conventions\n- Works with any LLM that supports tool calling\n\n**Anthropic Skills** (application level): Pre-packaged, reusable task modules [^2][^1]\n- Combine instructions + tools + resources\n- Teach Claude specialized workflows\n- Portable across Claude.ai, API, desktop\n\n## Key differences:\n\n**MCP**: Protocol for *how* tools are exposed and called\n```javascript\n// Generic tool interface\nawait client.request(\"tools/call\", { name: \"add\", arguments: {...} });\n```\n\n**Skills**: Pre-configured *what* Claude should do\n```\nSkill: \"Data Analysis\"\n- Instructions: \"Analyze CSV files...\"\n- Tools: [read_file, calculate_stats, create_chart]\n- Resources: [example_data.csv, templates/]\n```\n\n**Relationship:**\n- Skills can *use* MCP servers as their tool backend\n- MCP provides the plumbing, Skills provide the task definition\n- Skills = instructions + MCP tools + context\n\nSkills are Anthropic-specific; MCP is vendor-neutral. [^3][^2]","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">33</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">9,292</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.03 / 0.30</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">19.38</span>\n</li>\n\n","documents":[]},{"id":"3aa5ea9e-4d7a-428b-935d-ec29390bf8a7","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T20:58:42Z","state":"done","prompt":"Go a little deeper on skills do they need mcp?","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://www.anthropic.com/news/skills\" >Claude Skills: Customize AI for your workflows</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 53%, transparent 53%)\">53%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.anthropic.com/news/agent-capabilities-api\" >New capabilities for building agents on the Anthropic API \\ Anthropic</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 25%, transparent 25%)\">25%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.anthropic.com/news/model-context-protocol\" >Introducing the Model Context Protocol \\ Anthropic</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 22%, transparent 22%)\">22%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Claude Skills: Customize AI for your workflows](https://www.anthropic.com/news/skills) (53%)\n[^2]: [New capabilities for building agents on the Anthropic API \\ Anthropic](https://www.anthropic.com/news/agent-capabilities-api) (25%)\n[^3]: [Introducing the Model Context Protocol \\ Anthropic](https://www.anthropic.com/news/model-context-protocol) (22%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Anthropic Skills MCP</li></ul></summary> Sources (3):<br>\n<strong>Claude Skills: Customize AI for your workflows</strong><br>\n<a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">https://www.anthropic.com/news/skills</a><br>\nOct 16, 2025 Use Anthropic-created skills to have Claude read and generate professional Excel spreadsheets with formulas, PowerPoint presentations, Word ...\n\n<p><strong>Introducing the Model Context Protocol \\ Anthropic</strong><br>\n<a href=\"https://www.anthropic.com/news/model-context-protocol\" target=\"_blank\">https://www.anthropic.com/news/model-context-protocol</a><br>\nNov 25, 2024 The Model Context Protocol (MCP) is an open standard for connecting AI assistants to the systems where data lives, including content repositories, business tools, and development environments. Its aim is to help frontier models produce better, more relevant responses.</p>\n<p><strong>New capabilities for building agents on the Anthropic API \\ Anthropic</strong><br>\n<a href=\"https://www.anthropic.com/news/agent-capabilities-api\" target=\"_blank\">https://www.anthropic.com/news/agent-capabilities-api</a><br>\nMay 22, 2025 The MCP connector on the Anthropic API enables developers to connect Claude to any remote Model Context Protocol (MCP) server without writing client code. Previously, connecting to MCP servers required building your own client harness to handle MCP connections. Now, the Anthropic API handles all connection management, tool discovery, and error handling automatically.</p>\n</details><h1>Anthropic Skills - Deeper Dive</h1>\n<p><strong>Skills do NOT require MCP.</strong> They're independent concepts that can work together. <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/skills#:~:text=Use%20Anthropic-created,presentations%2C%20Word\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Claude Skills: Customize AI for your workflows</b></a><span class=\"passage\">Use Anthropic-created skills to have Claude read and generate professional Excel spreadsheets with formulas, PowerPoint presentations, Word ...</span></span></sup><sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/model-context-protocol\" target=\"_blank\">3</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/model-context-protocol#:~:text=The%20Model,relevant%20responses.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>3. Introducing the Model Context Protocol \\ Anthropic</b></a><span class=\"passage\">The Model Context Protocol (MCP) is an open standard for connecting AI assistants to the systems where data lives, including content repositories, business tools, and development environments. Its aim is to help frontier models produce better, more relevant responses.</span></span></sup></p>\n<h2>What Skills Actually Are</h2>\n<p>Skills are pre-packaged workflow definitions containing: <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/skills#:~:text=Use%20Anthropic-created,presentations%2C%20Word\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Claude Skills: Customize AI for your workflows</b></a><span class=\"passage\">Use Anthropic-created skills to have Claude read and generate professional Excel spreadsheets with formulas, PowerPoint presentations, Word ...</span></span></sup></p>\n<ol>\n<li><strong>Instructions</strong>: Custom system prompts for specific tasks</li>\n<li><strong>Tools</strong>: Functions Claude can call (can be anything, not just MCP)</li>\n<li><strong>Resources</strong>: Context files, templates, examples</li>\n<li><strong>Configuration</strong>: Parameters, settings, constraints</li>\n</ol>\n<h2>Skills Without MCP</h2>\n<div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"c\">// Skill definition (conceptual)</span>\n<span class=\"p\">{</span>\n name: <span class=\"s\">\"Excel Analysis\"</span><span class=\"p\">,</span>\n instructions: <span class=\"s\">\"You are an Excel expert. Analyze spreadsheets...\"</span><span class=\"p\">,</span>\n tools: <span class=\"p\">[</span>\n <span class=\"c\">// Could be native API tools</span>\n <span class=\"p\">{</span> name: <span class=\"s\">\"read_excel\"</span><span class=\"p\">,</span> implementation: <span class=\"n\">nativeFunction</span> <span class=\"p\">}</span><span class=\"p\">,</span>\n <span class=\"p\">{</span> name: <span class=\"s\">\"create_chart\"</span><span class=\"p\">,</span> implementation: <span class=\"n\">nativeFunction</span> <span class=\"p\">}</span>\n <span class=\"p\">]</span><span class=\"p\">,</span>\n resources: <span class=\"p\">[</span><span class=\"s\">\"templates/report.xlsx\"</span><span class=\"p\">]</span>\n<span class=\"p\">}</span>\n</code></pre></div>\n<p>Anthropic provides built-in Skills (Excel, PowerPoint, Word) that use their own tool implementations. <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/skills#:~:text=Use%20Anthropic-created,presentations%2C%20Word\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Claude Skills: Customize AI for your workflows</b></a><span class=\"passage\">Use Anthropic-created skills to have Claude read and generate professional Excel spreadsheets with formulas, PowerPoint presentations, Word ...</span></span></sup></p>\n<h2>Skills With MCP</h2>\n<p>MCP becomes relevant when you want Skills to access external systems:</p>\n<div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"c\">// Skill using MCP backend</span>\n<span class=\"p\">{</span>\n name: <span class=\"s\">\"Database Analysis\"</span><span class=\"p\">,</span>\n instructions: <span class=\"s\">\"Analyze database queries...\"</span><span class=\"p\">,</span>\n tools: <span class=\"p\">[</span>\n <span class=\"c\">// Tools exposed via MCP server</span>\n <span class=\"p\">{</span> source: <span class=\"s\">\"mcp://database-server/query\"</span> <span class=\"p\">}</span><span class=\"p\">,</span>\n <span class=\"p\">{</span> source: <span class=\"s\">\"mcp://database-server/schema\"</span> <span class=\"p\">}</span>\n <span class=\"p\">]</span>\n<span class=\"p\">}</span>\n</code></pre></div>\n<p>The Anthropic API now has an <strong>MCP connector</strong> that handles this automatically. <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/agent-capabilities-api\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/agent-capabilities-api#:~:text=The%20MCP,handling%20automatically.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>2. New capabilities for building agents on the Anthropic API \\ Anthropic</b></a><span class=\"passage\">The MCP connector on the Anthropic API enables developers to connect Claude to any remote Model Context Protocol (MCP) server without writing client code. Previously, connecting to MCP servers required building your own client harness to handle MCP connections. Now, the Anthropic API handles all connection management, tool discovery, and error handling automatically.</span></span></sup> Instead of building your own MCP client, you just point the Skill at an MCP server URL.</p>\n<h2>Key Distinction</h2>\n<ul>\n<li><strong>Skills</strong>: Task definition layer (what Claude should do)</li>\n<li><strong>MCP</strong>: Tool access layer (how to reach external systems)</li>\n</ul>\n<p>Skills can use:</p>\n<ul>\n<li>Native Anthropic tools</li>\n<li>Custom API endpoints</li>\n<li>MCP servers</li>\n<li>Any combination</li>\n</ul>\n<p>MCP is <em>one option</em> for providing tools to Skills, not a requirement. It's most useful when you want standardized access to external data sources.</p>","md":"# Anthropic Skills - Deeper Dive\n\n**Skills do NOT require MCP.** They're independent concepts that can work together. [^1][^3]\n\n## What Skills Actually Are\n\nSkills are pre-packaged workflow definitions containing: [^1]\n\n1. **Instructions**: Custom system prompts for specific tasks\n2. **Tools**: Functions Claude can call (can be anything, not just MCP)\n3. **Resources**: Context files, templates, examples\n4. **Configuration**: Parameters, settings, constraints\n\n## Skills Without MCP\n\n```javascript\n// Skill definition (conceptual)\n{\n name: \"Excel Analysis\",\n instructions: \"You are an Excel expert. Analyze spreadsheets...\",\n tools: [\n // Could be native API tools\n { name: \"read_excel\", implementation: nativeFunction },\n { name: \"create_chart\", implementation: nativeFunction }\n ],\n resources: [\"templates/report.xlsx\"]\n}\n```\n\nAnthropic provides built-in Skills (Excel, PowerPoint, Word) that use their own tool implementations. [^1]\n\n## Skills With MCP\n\nMCP becomes relevant when you want Skills to access external systems:\n\n```javascript\n// Skill using MCP backend\n{\n name: \"Database Analysis\",\n instructions: \"Analyze database queries...\",\n tools: [\n // Tools exposed via MCP server\n { source: \"mcp://database-server/query\" },\n { source: \"mcp://database-server/schema\" }\n ]\n}\n```\n\nThe Anthropic API now has an **MCP connector** that handles this automatically. [^2] Instead of building your own MCP client, you just point the Skill at an MCP server URL.\n\n## Key Distinction\n\n- **Skills**: Task definition layer (what Claude should do)\n- **MCP**: Tool access layer (how to reach external systems)\n\nSkills can use:\n- Native Anthropic tools\n- Custom API endpoints\n- MCP servers\n- Any combination\n\nMCP is *one option* for providing tools to Skills, not a requirement. It's most useful when you want standardized access to external data sources.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">36</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">9,484</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.03 / 0.33</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">21.68</span>\n</li>\n\n","documents":[]},{"id":"2a7290ca-882a-4e9c-bdc3-5107c84e0fd4","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T21:01:48Z","branch_list":["00000000-0000-4000-0000-000000000000","0262e960-4d25-432d-8335-4035feaf6525"],"state":"done","prompt":"So what about the desktop app of Anthropic. Can it call tools from skills without mcp?","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://www.anthropic.com/news/model-context-protocol\" >Introducing the Model Context Protocol \\ Anthropic</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 63%, transparent 63%)\">63%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.anthropic.com/engineering/desktop-extensions\" >Claude Desktop Extensions: One-click MCP server installation for...</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 31%, transparent 31%)\">31%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.anthropic.com/news/skills\" >Claude Skills: Customize AI for your workflows</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 6%, transparent 6%)\">6%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Introducing the Model Context Protocol \\ Anthropic](https://www.anthropic.com/news/model-context-protocol) (63%)\n[^2]: [Claude Desktop Extensions: One-click MCP server installation for...](https://www.anthropic.com/engineering/desktop-extensions) (31%)\n[^3]: [Claude Skills: Customize AI for your workflows](https://www.anthropic.com/news/skills) (6%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Anthropic desktop app skills without MCP</li>\n<li>Anthropic desktop app tool calling</li></ul></summary> Sources (6):<br>\n<strong>Claude Skills: Customize AI for your workflows</strong><br>\n<a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">https://www.anthropic.com/news/skills</a><br>\nOct 16, 2025 Build custom Skills to teach Claude specialized tasks. Create once, use everywhere—from spreadsheets to coding. Available across Claude.ai, ...\n\n<p><strong>Claude Desktop Extensions: One-click MCP server installation for...</strong><br>\n<a href=\"https://www.anthropic.com/engineering/desktop-extensions\" target=\"_blank\">https://www.anthropic.com/engineering/desktop-extensions</a><br>\nJun 26, 2025 A Desktop Extension is a zip archive containing the local MCP server as well as a manifest.json, which describes everything Claude Desktop and other apps supporting desktop extensions need to know.</p>\n<p><strong>Introducing the Model Context Protocol \\ Anthropic</strong><br>\n<a href=\"https://www.anthropic.com/news/model-context-protocol\" target=\"_blank\">https://www.anthropic.com/news/model-context-protocol</a><br>\nNov 25, 2024 The Model Context Protocol specification and SDKs Local MCP server support in the Claude Desktop apps An open-source repository of MCP servers Claude 3.5 Sonnet is adept at quickly building MCP server implementations, making it easy for organizations and individuals to rapidly connect their most important datasets with a range of AI-powered tools.</p>\n<p><strong>Parallel Tool Calling in Desktop App? : r/Anthropic</strong><br>\n<a href=\"https://www.reddit.com/r/Anthropic/comments/1kt04yq/parallel_tool_calling_in_desktop_app/\" target=\"_blank\">https://www.reddit.com/r/Anthropic/comments/1kt04yq/parallel_tool_calling_in_desktop_app/</a><br>\n Anybody seeing parallel tool calls working in the Desktop app? Whenever I prompt it to make multiple tool calls at once, I get an error ...</p>\n<p><strong>Writing effective tools for AI agents—using AI agents \\ Anthropic</strong><br>\n<a href=\"https://www.anthropic.com/engineering/writing-tools-for-agents\" target=\"_blank\">https://www.anthropic.com/engineering/writing-tools-for-agents</a><br>\nSep 11, 2025 ... tools in Claude Code or the Claude Desktop app. To connect your ... tool-calling behaviors. When writing tool descriptions and specs ...</p>\n<p><strong>Claude Desktop Extensions: One-click MCP server installation for...</strong><br>\n<a href=\"https://www.anthropic.com/engineering/desktop-extensions\" target=\"_blank\">https://www.anthropic.com/engineering/desktop-extensions</a><br>\nJun 26, 2025 <strong>Test considerations:</strong> - Validate that all tool calls return ... tools, data, and applications users already have on their local machines.</p>\n</details><h1>Claude Desktop App & Tools</h1>\n<p><strong>Claude Desktop primarily uses MCP for tool execution.</strong> <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/model-context-protocol\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/model-context-protocol#:~:text=The%20Model,AI-powered%20tools.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Introducing the Model Context Protocol \\ Anthropic</b></a><span class=\"passage\">The Model Context Protocol specification and SDKs Local MCP server support in the Claude Desktop apps An open-source repository of MCP servers Claude 3.5 Sonnet is adept at quickly building MCP server implementations, making it easy for organizations and individuals to rapidly connect their most important datasets with a range of AI-powered tools.</span></span></sup><sup class=\"trigger\"><a href=\"https://www.anthropic.com/engineering/desktop-extensions\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/engineering/desktop-extensions#:~:text=A%20Desktop,to%20know.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>2. Claude Desktop Extensions: One-click MCP server installation for...</b></a><span class=\"passage\">A Desktop Extension is a zip archive containing the local MCP server as well as a manifest.json, which describes everything Claude Desktop and other apps supporting desktop extensions need to know.</span></span></sup></p>\n<h2>How it works:</h2>\n<p><strong>Built-in Skills</strong> (Excel, PowerPoint, Word):</p>\n<ul>\n<li>Use native tool implementations</li>\n<li>Don't require MCP configuration</li>\n<li>Work out of the box <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/skills\" target=\"_blank\">3</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/skills#:~:text=Build%20custom,across%20Claude.ai%2C\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>3. Claude Skills: Customize AI for your workflows</b></a><span class=\"passage\">Build custom Skills to teach Claude specialized tasks. Create once, use everywhere—from spreadsheets to coding. Available across Claude.ai, ...</span></span></sup></li>\n</ul>\n<p><strong>Custom/External tools</strong>:</p>\n<ul>\n<li><strong>Require MCP servers</strong> <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/model-context-protocol\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/model-context-protocol#:~:text=The%20Model,AI-powered%20tools.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Introducing the Model Context Protocol \\ Anthropic</b></a><span class=\"passage\">The Model Context Protocol specification and SDKs Local MCP server support in the Claude Desktop apps An open-source repository of MCP servers Claude 3.5 Sonnet is adept at quickly building MCP server implementations, making it easy for organizations and individuals to rapidly connect their most important datasets with a range of AI-powered tools.</span></span></sup></li>\n<li>Desktop app connects to local MCP servers via stdio</li>\n<li>Configuration in <code>claude_desktop_config.json</code>:</li>\n</ul>\n<div class=\"codehilite\"><span class=\"filename\">Json</span><pre><span></span><code><span class=\"p\">{</span>\n <span class=\"s\">\"mcpServers\"</span>: <span class=\"p\">{</span>\n <span class=\"s\">\"filesystem\"</span>: <span class=\"p\">{</span>\n <span class=\"s\">\"command\"</span>: <span class=\"s\">\"node\"</span><span class=\"p\">,</span>\n <span class=\"s\">\"args\"</span>: <span class=\"p\">[</span><span class=\"s\">\"/path/to/filesystem-server.js\"</span><span class=\"p\">]</span>\n <span class=\"p\">}</span>\n <span class=\"p\">}</span>\n<span class=\"p\">}</span>\n</code></pre></div>\n<h2>Desktop Extensions</h2>\n<p>Anthropic introduced <strong>Desktop Extensions</strong> for easier MCP server installation: <sup class=\"trigger\"><a href=\"https://www.anthropic.com/engineering/desktop-extensions\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/engineering/desktop-extensions#:~:text=A%20Desktop,to%20know.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>2. Claude Desktop Extensions: One-click MCP server installation for...</b></a><span class=\"passage\">A Desktop Extension is a zip archive containing the local MCP server as well as a manifest.json, which describes everything Claude Desktop and other apps supporting desktop extensions need to know.</span></span></sup></p>\n<ul>\n<li>Zip archive containing MCP server + manifest</li>\n<li>One-click installation</li>\n<li>Desktop app automatically manages the MCP connection</li>\n</ul>\n<h2>The Architecture</h2>\n<div class=\"codehilite\"><span class=\"filename\">Plaintext</span><pre><span></span><code>Claude Desktop (Host)\n├── Built-in Skills → Native tools (no MCP)\n└── Custom Skills → MCP servers → External tools\n</code></pre></div>\n<p><strong>Answer to your question:</strong></p>\n<p>Skills in the desktop app <strong>can</strong> use non-MCP tools (the built-in ones), but for any custom/external tool access, the desktop app architecture is built around MCP. <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/model-context-protocol\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/model-context-protocol#:~:text=The%20Model,AI-powered%20tools.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Introducing the Model Context Protocol \\ Anthropic</b></a><span class=\"passage\">The Model Context Protocol specification and SDKs Local MCP server support in the Claude Desktop apps An open-source repository of MCP servers Claude 3.5 Sonnet is adept at quickly building MCP server implementations, making it easy for organizations and individuals to rapidly connect their most important datasets with a range of AI-powered tools.</span></span></sup> You can't easily add arbitrary tool implementations without going through MCP.</p>\n<p>This design choice makes sense: MCP provides the standardized interface the desktop app needs to safely sandbox and manage external tool execution.</p>","md":"# Claude Desktop App & Tools\n\n**Claude Desktop primarily uses MCP for tool execution.** [^1][^2]\n\n## How it works:\n\n**Built-in Skills** (Excel, PowerPoint, Word):\n- Use native tool implementations\n- Don't require MCP configuration\n- Work out of the box [^3]\n\n**Custom/External tools**:\n- **Require MCP servers** [^1]\n- Desktop app connects to local MCP servers via stdio\n- Configuration in `claude_desktop_config.json`:\n\n```json\n{\n \"mcpServers\": {\n \"filesystem\": {\n \"command\": \"node\",\n \"args\": [\"/path/to/filesystem-server.js\"]\n }\n }\n}\n```\n\n## Desktop Extensions\n\nAnthropic introduced **Desktop Extensions** for easier MCP server installation: [^2]\n\n- Zip archive containing MCP server + manifest\n- One-click installation\n- Desktop app automatically manages the MCP connection\n\n## The Architecture\n\n```\nClaude Desktop (Host)\n├── Built-in Skills → Native tools (no MCP)\n└── Custom Skills → MCP servers → External tools\n```\n\n**Answer to your question:**\n\nSkills in the desktop app **can** use non-MCP tools (the built-in ones), but for any custom/external tool access, the desktop app architecture is built around MCP. [^1] You can't easily add arbitrary tool implementations without going through MCP.\n\nThis design choice makes sense: MCP provides the standardized interface the desktop app needs to safely sandbox and manage external tool execution.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">33</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">10,025</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.02 / 0.35</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">18.13</span>\n</li>\n\n","documents":[]},{"id":"b642a1ab-696b-4d7e-be60-ad6b0a06521d","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-03T21:03:14Z","state":"done","prompt":"But the desktop app also has a vm or something like this","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://www.anthropic.com/news/claude-code-on-the-web\" >Claude Code on the web</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 56%, transparent 56%)\">56%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://www.anthropic.com/engineering/claude-code-sandboxing\" >Making Claude Code more secure and autonomous with ...</a>\n <span class=\"__domain-name\">www.anthropic.com</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 44%, transparent 44%)\">44%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Claude Code on the web](https://www.anthropic.com/news/claude-code-on-the-web) (56%)\n[^2]: [Making Claude Code more secure and autonomous with ...](https://www.anthropic.com/engineering/claude-code-sandboxing) (44%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Anthropic Claude desktop app VM</li>\n<li>Claude desktop app sandbox environment</li></ul></summary> Sources (6):<br>\n<strong>Download Claude</strong><br>\n<a href=\"https://www.claude.com/download\" target=\"_blank\">https://www.claude.com/download</a><br>\nClaude desktop app supports standard enterprise deployment with MSIX installers (Windows) and PKG installers (Mac). You can control version updates to test and ...\n\n<p><strong>Claude Desktop (2025) Ultimate Guide: Download, Features & Setup</strong><br>\n<a href=\"https://skywork.ai/blog/ai-agent/claude-desktop-2025-ultimate-guide/\" target=\"_blank\">https://skywork.ai/blog/ai-agent/claude-desktop-2025-ultimate-guide/</a><br>\n Discover the complete 2025 guide to Claude Desktop: installation, new features, plans, admin tips, workflows & troubleshooting. Install and master the latest Anthropic app now!</p>\n<p><strong>How to Use Claude Computer Use (2025)</strong><br>\n<a href=\"https://skywork.ai/blog/how-to-use-claude-computer-use-automation-guide/\" target=\"_blank\">https://skywork.ai/blog/how-to-use-claude-computer-use-automation-guide/</a><br>\nOct 16, 2025 This guide shows you how to safely enable Anthropic's Computer Use, watch it operate a contained virtual desktop, and complete three practical ...</p>\n<p><strong>Making Claude Code more secure and autonomous with ...</strong><br>\n<a href=\"https://www.anthropic.com/engineering/claude-code-sandboxing\" target=\"_blank\">https://www.anthropic.com/engineering/claude-code-sandboxing</a><br>\nOct 20, 2025 Claude Code on the web executes each Claude Code session in an isolated sandbox where it has full access to its server in a safe and secure way.</p>\n<p><strong>Claude Code on the web</strong><br>\n<a href=\"https://www.anthropic.com/news/claude-code-on-the-web\" target=\"_blank\">https://www.anthropic.com/news/claude-code-on-the-web</a><br>\nOct 20, 2025 Every Claude Code task runs in an isolated sandbox environment with network and filesystem restrictions. Git interactions are handled ...</p>\n<p><strong>GitHub - mlesyk/claude-desktop</strong><br>\n<a href=\"https://github.com/mlesyk/claude-desktop\" target=\"_blank\">https://github.com/mlesyk/claude-desktop</a><br>\nJun 01, 2025 Contribute to mlesyk/claude-desktop development by creating an account on GitHub.Sandbox Launch Options: Interactive dialog to choose between sandboxed (secure isolation) or direct (system access) execution modes. Multi-Sandbox Support: Create and manage multiple isolated sandbox environments for different projects or security contexts.</p>\n</details><h1>Claude Desktop Sandboxing</h1>\n<p>Yes, <strong>Claude Desktop has sandbox environments</strong> for secure code execution. <sup class=\"trigger\"><a href=\"https://www.anthropic.com/engineering/claude-code-sandboxing\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/engineering/claude-code-sandboxing#:~:text=Claude%20Code,secure%20way.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>2. Making Claude Code more secure and autonomous with ...</b></a><span class=\"passage\">Claude Code on the web executes each Claude Code session in an isolated sandbox where it has full access to its server in a safe and secure way.</span></span></sup><sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/claude-code-on-the-web\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/claude-code-on-the-web#:~:text=Every%20Claude,are%20handled\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Claude Code on the web</b></a><span class=\"passage\">Every Claude Code task runs in an isolated sandbox environment with network and filesystem restrictions. Git interactions are handled ...</span></span></sup></p>\n<h2>Two Different Capabilities</h2>\n<p><strong>1. Code Execution Sandbox</strong> (Claude Code):</p>\n<ul>\n<li>Isolated container for running code</li>\n<li>Network and filesystem restrictions <sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/claude-code-on-the-web\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/claude-code-on-the-web#:~:text=Every%20Claude,are%20handled\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Claude Code on the web</b></a><span class=\"passage\">Every Claude Code task runs in an isolated sandbox environment with network and filesystem restrictions. Git interactions are handled ...</span></span></sup></li>\n<li>Separate from MCP tool execution</li>\n<li>Used when Claude writes/runs code directly</li>\n</ul>\n<p><strong>2. MCP Tool Execution</strong>:</p>\n<ul>\n<li>Runs in separate processes via stdio</li>\n<li>Not sandboxed by default (runs with your system permissions)</li>\n<li>Desktop app spawns MCP servers as child processes</li>\n</ul>\n<h2>The Architecture</h2>\n<div class=\"codehilite\"><span class=\"filename\">Plaintext</span><pre><span></span><code>Claude Desktop\n├── Code Sandbox (isolated container)\n│ └── Python/Node/etc. execution\n│\n└── MCP Servers (subprocess, not sandboxed)\n ├── Filesystem server (your permissions)\n ├── Database server (your permissions)\n └── Custom servers (your permissions)\n</code></pre></div>\n<h2>Security Model</h2>\n<p><strong>Code Sandbox</strong>: <sup class=\"trigger\"><a href=\"https://www.anthropic.com/engineering/claude-code-sandboxing\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/engineering/claude-code-sandboxing#:~:text=Claude%20Code,secure%20way.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>2. Making Claude Code more secure and autonomous with ...</b></a><span class=\"passage\">Claude Code on the web executes each Claude Code session in an isolated sandbox where it has full access to its server in a safe and secure way.</span></span></sup><sup class=\"trigger\"><a href=\"https://www.anthropic.com/news/claude-code-on-the-web\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://www.anthropic.com/news/claude-code-on-the-web#:~:text=Every%20Claude,are%20handled\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJw9sZYwtCakJTNhXBGOIYDygIU6Kx0C3RBsPojAq67lA%3D\"> www.anthropic.com</span><b>1. Claude Code on the web</b></a><span class=\"passage\">Every Claude Code task runs in an isolated sandbox environment with network and filesystem restrictions. Git interactions are handled ...</span></span></sup></p>\n<ul>\n<li>Claude-written code runs isolated</li>\n<li>Limited filesystem/network access</li>\n<li>Safe for arbitrary code execution</li>\n</ul>\n<p><strong>MCP Servers</strong>:</p>\n<ul>\n<li>Run with your user permissions</li>\n<li>Access what you configure them to access</li>\n<li>Security depends on server implementation</li>\n</ul>\n<h2>Answer to Your Question</h2>\n<p>The sandbox is for <strong>code execution</strong>, not tool calling. Skills still need MCP for external tool access. The sandbox doesn't replace MCP—it's a separate security layer for when Claude generates and runs code directly.</p>\n<p><strong>Example flow:</strong></p>\n<ol>\n<li>User asks Claude to analyze a file</li>\n<li>Claude uses MCP filesystem server (not sandboxed) to read file</li>\n<li>Claude writes Python analysis code</li>\n<li>Code runs in sandbox (isolated)</li>\n<li>Results returned to user</li>\n</ol>\n<p>The VM/sandbox and MCP serve different purposes in the security model.</p>","md":"# Claude Desktop Sandboxing\n\nYes, **Claude Desktop has sandbox environments** for secure code execution. [^2][^1]\n\n## Two Different Capabilities\n\n**1. Code Execution Sandbox** (Claude Code):\n- Isolated container for running code\n- Network and filesystem restrictions [^1]\n- Separate from MCP tool execution\n- Used when Claude writes/runs code directly\n\n**2. MCP Tool Execution**:\n- Runs in separate processes via stdio\n- Not sandboxed by default (runs with your system permissions)\n- Desktop app spawns MCP servers as child processes\n\n## The Architecture\n\n```\nClaude Desktop\n├── Code Sandbox (isolated container)\n│ └── Python/Node/etc. execution\n│\n└── MCP Servers (subprocess, not sandboxed)\n ├── Filesystem server (your permissions)\n ├── Database server (your permissions)\n └── Custom servers (your permissions)\n```\n\n## Security Model\n\n**Code Sandbox**: [^2][^1]\n- Claude-written code runs isolated\n- Limited filesystem/network access\n- Safe for arbitrary code execution\n\n**MCP Servers**:\n- Run with your user permissions\n- Access what you configure them to access\n- Security depends on server implementation\n\n## Answer to Your Question\n\nThe sandbox is for **code execution**, not tool calling. Skills still need MCP for external tool access. The sandbox doesn't replace MCP—it's a separate security layer for when Claude generates and runs code directly.\n\n**Example flow:**\n1. User asks Claude to analyze a file\n2. Claude uses MCP filesystem server (not sandboxed) to read file\n3. Claude writes Python analysis code\n4. Code runs in sandbox (isolated)\n5. Results returned to user\n\nThe VM/sandbox and MCP serve different purposes in the security model.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">33</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">10,340</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.02 / 0.37</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">20.19</span>\n</li>\n\n","documents":[]},{"id":"13e88519-9a8b-47c2-b44d-e28c0443e102","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-05T04:25:31Z","state":"done","prompt":"Explain the features the client can provide. Root? ","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" >Overview - Model Context Protocol</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 100%, transparent 100%)\">100%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Overview - Model Context Protocol](https://modelcontextprotocol.io/specification/2025-03-26/basic) (100%)\n","reply":"<details><summary>Gathered key details from:<p></p>\n<ul>\n<li><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">Overview - Model Context Protocol</a></li></ul></summary>\n\n<h3>Query</h3>\n<p>What features can the client provide in MCP, specifically regarding \"root\"?</p>\n<h3>Response</h3>\n<p>The client can provide sampling and root directory lists.</p>\n</details><h1>Client-Provided Features</h1>\n<p>The MCP client can provide two capabilities to servers: <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic#:~:text=The%20client,directory%20lists.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Overview - Model Context Protocol</b></a><span class=\"passage\">The client can provide sampling and root directory lists.</span></span></sup></p>\n<h2>1. Sampling</h2>\n<p>Allows servers to request LLM completions from the client's AI model.</p>\n<p><strong>Use case</strong>: Server needs AI assistance during tool execution</p>\n<div class=\"codehilite\"><span class=\"filename\">Typescript</span><pre><span></span><code>// Server requests sampling from client\n{\n \"method\": \"sampling/createMessage\",\n \"params\": {\n \"messages\": [\n { \"role\": \"user\", \"content\": \"Summarize this data...\" }\n ],\n \"maxTokens\": 100\n }\n}\n</code></pre></div>\n<p><strong>Why useful</strong>: Servers can leverage the host's LLM without needing their own API keys or model access.</p>\n<h2>2. Roots (Directory Lists)</h2>\n<p>Client declares accessible filesystem roots to inform servers about boundaries.</p>\n<p><strong>Use case</strong>: Filesystem servers need to know which directories they can access</p>\n<div class=\"codehilite\"><span class=\"filename\">Typescript</span><pre><span></span><code>// Client declares roots during initialization\n{\n \"method\": \"initialize\",\n \"params\": {\n \"capabilities\": {\n \"roots\": {\n \"listChanged\": true // Client will notify of changes\n }\n }\n }\n}\n\n// Client provides root list\n{\n \"method\": \"roots/list\",\n \"result\": {\n \"roots\": [\n { \"uri\": \"file:///home/user/projects\", \"name\": \"Projects\" },\n { \"uri\": \"file:///home/user/documents\", \"name\": \"Documents\" }\n ]\n }\n}\n</code></pre></div>\n<p><strong>Why useful</strong>: Servers can scope operations to allowed directories, improving security and UX. Client can update roots dynamically via <code>notifications/roots/list_changed</code>. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-03-26/basic#:~:text=The%20client,directory%20lists.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Overview - Model Context Protocol</b></a><span class=\"passage\">The client can provide sampling and root directory lists.</span></span></sup></p>\n<p>Both features are optional—servers declare if they need them during capability negotiation.</p>","md":"# Client-Provided Features\n\nThe MCP client can provide two capabilities to servers: [^1]\n\n## 1. Sampling\n\nAllows servers to request LLM completions from the client's AI model.\n\n**Use case**: Server needs AI assistance during tool execution\n\n```typescript\n// Server requests sampling from client\n{\n \"method\": \"sampling/createMessage\",\n \"params\": {\n \"messages\": [\n { \"role\": \"user\", \"content\": \"Summarize this data...\" }\n ],\n \"maxTokens\": 100\n }\n}\n```\n\n**Why useful**: Servers can leverage the host's LLM without needing their own API keys or model access.\n\n## 2. Roots (Directory Lists)\n\nClient declares accessible filesystem roots to inform servers about boundaries.\n\n**Use case**: Filesystem servers need to know which directories they can access\n\n```typescript\n// Client declares roots during initialization\n{\n \"method\": \"initialize\",\n \"params\": {\n \"capabilities\": {\n \"roots\": {\n \"listChanged\": true // Client will notify of changes\n }\n }\n }\n}\n\n// Client provides root list\n{\n \"method\": \"roots/list\",\n \"result\": {\n \"roots\": [\n { \"uri\": \"file:///home/user/projects\", \"name\": \"Projects\" },\n { \"uri\": \"file:///home/user/documents\", \"name\": \"Documents\" }\n ]\n }\n}\n```\n\n**Why useful**: Servers can scope operations to allowed directories, improving security and UX. Client can update roots dynamically via `notifications/roots/list_changed`. [^1]\n\nBoth features are optional—servers declare if they need them during capability negotiation.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">39</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">10,409</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.06 / 0.44</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">17.28</span>\n</li>\n\n","documents":[]},{"id":"eedb5c2a-1ba5-4edf-85c5-7f67dcd82860","thread_id":"d0ec1459-05b9-4fed-b3ec-f1617b9035a6","created_at":"2025-11-05T04:30:25Z","state":"done","prompt":"But how is this list enforced? Is this up to the host application?","references_html":"<ol data-ref-list>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices\" >Security Best Practices - Model Context Protocol</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 62%, transparent 62%)\">62%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/specification/2024-11-05/client/roots\" >Roots - Model Context Protocol</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 20%, transparent 20%)\">20%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n <li>\n <a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" >Understanding MCP clients - Model Context Protocol</a>\n <span class=\"__domain-name\">modelcontextprotocol.io</span>\n <div class=\"trigger\" tabindex=\"0\">\n <span class=\"contribution\" style=\"background: linear-gradient(to right, var(--primary-70) 18%, transparent 18%)\">18%</span>\n <div class=\"tooltip top end tooltip_base tw-auto\">\n This percentage indicates how much a source has contributed to the answer.\n </div>\n </div>\n </li>\n \n</ol>\n","references_md":"[^1]: [Security Best Practices - Model Context Protocol](https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices) (62%)\n[^2]: [Roots - Model Context Protocol](https://modelcontextprotocol.io/specification/2024-11-05/client/roots) (20%)\n[^3]: [Understanding MCP clients - Model Context Protocol](https://modelcontextprotocol.io/docs/learn/client-concepts) (18%)\n","reply":"<details><summary>Searched with Kagi<p></p>\n<ul>\n<li>Model Context Protocol roots enforcement</li>\n<li>MCP roots security</li></ul></summary> Sources (6):<br>\n<strong>Understanding Roots in Model Context Protocol (MCP)</strong><br>\n<a href=\"https://workos.com/blog/mcp-roots-guide\" target=\"_blank\">https://workos.com/blog/mcp-roots-guide</a><br>\nJul 14, 2025 Roots in MCP are a simple but powerful mechanism for defining workspace boundaries and resource scopes. They help clients and servers coordinate ...\n\n<p><strong>What is the Model Context Protocol (MCP)? — WorkOS Guides</strong><br>\n<a href=\"https://workos.com/guide/model-context-protocol\" target=\"_blank\">https://workos.com/guide/model-context-protocol</a><br>\nMar 07, 2025 Even advanced language models are often trained on incomplete or outdated datasets. By connecting them to live data—whether that’s Google Drive documents, official API docs, Slack messages, or an internal database—MCP helps ensure the model’s answers are up-to-date, context-rich, and domain-specific. Unified data access. Before MCP, a developer might have to juggle separate plugins, tokens, or custom wrappers to give an AI system access to multiple sources. With MCP, you configure one protocol, then the LLM can “see” all registered connectors.</p>\n<p><strong>Roots - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/specification/2024-11-05/client/roots\" target=\"_blank\">https://modelcontextprotocol.io/specification/2024-11-05/client/roots</a><br>\nNov 05, 2024 The Model Context Protocol (MCP) provides a standardized way for clients to expose filesystem “roots” to servers. Roots define the boundaries of where servers can operate within the filesystem, allowing them to understand which directories and files they have access to. Servers can request the list of roots from supporting clients and receive notifications when that list changes.</p>\n<p><strong>Roots</strong><br>\n<a href=\"https://modelcontextprotocol.io/specification/2025-06-18/client/roots\" target=\"_blank\">https://modelcontextprotocol.io/specification/2025-06-18/client/roots</a><br>\nJun 18, 2025 The Model Context Protocol (MCP) provides a standardized way for clients to expose filesystem “roots” to servers.</p>\n<p><strong>Understanding MCP clients - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" target=\"_blank\">https://modelcontextprotocol.io/docs/learn/client-concepts</a><br>\nJul 25, 2025 Roots serve as a coordination mechanism between clients and servers, not a security boundary. The specification requires that servers “SHOULD respect root ...</p>\n<p><strong>Security Best Practices - Model Context Protocol</strong><br>\n<a href=\"https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices\" target=\"_blank\">https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices</a><br>\nJun 18, 2025 This document provides security considerations for the Model Context Protocol (MCP), complementing the MCP Authorization specification. This document identifies security risks, attack vectors, and best practices specific to MCP implementations. The primary audience for this document includes developers implementing MCP authorization flows, MCP server operators, and security professionals evaluating MCP-based systems.</p>\n</details><h1>Roots Enforcement</h1>\n<p><strong>Roots are NOT enforced by MCP.</strong> They're a coordination mechanism, not a security boundary. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2024-11-05/client/roots\" target=\"_blank\">2</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2024-11-05/client/roots#:~:text=The%20Model,list%20changes.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>2. Roots - Model Context Protocol</b></a><span class=\"passage\">The Model Context Protocol (MCP) provides a standardized way for clients to expose filesystem “roots” to servers. Roots define the boundaries of where servers can operate within the filesystem, allowing them to understand which directories and files they have access to. Servers can request the list of roots from supporting clients and receive notifications when that list changes.</span></span></sup><sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" target=\"_blank\">3</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts#:~:text=Roots%20serve,respect%20root\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>3. Understanding MCP clients - Model Context Protocol</b></a><span class=\"passage\">Roots serve as a coordination mechanism between clients and servers, not a security boundary. The specification requires that servers “SHOULD respect root ...</span></span></sup></p>\n<h2>How It Works</h2>\n<p><strong>Specification says</strong>: Servers \"SHOULD respect\" roots <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts\" target=\"_blank\">3</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/docs/learn/client-concepts#:~:text=Roots%20serve,respect%20root\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>3. Understanding MCP clients - Model Context Protocol</b></a><span class=\"passage\">Roots serve as a coordination mechanism between clients and servers, not a security boundary. The specification requires that servers “SHOULD respect root ...</span></span></sup></p>\n<p>This means:</p>\n<ul>\n<li>Roots are <strong>advisory</strong>, not mandatory</li>\n<li>Servers are expected to honor them voluntarily</li>\n<li>No protocol-level enforcement exists</li>\n</ul>\n<h2>Actual Enforcement</h2>\n<p><strong>Host application responsibility</strong>: <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices#:~:text=This%20document,MCP-based%20systems.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Security Best Practices - Model Context Protocol</b></a><span class=\"passage\">This document provides security considerations for the Model Context Protocol (MCP), complementing the MCP Authorization specification. This document identifies security risks, attack vectors, and best practices specific to MCP implementations. The primary audience for this document includes developers implementing MCP authorization flows, MCP server operators, and security professionals evaluating MCP-based systems.</span></span></sup></p>\n<p>The host must implement security measures:</p>\n<div class=\"codehilite\"><span class=\"filename\">Javascript</span><pre><span></span><code><span class=\"c\">// Host-level enforcement example</span>\n<span class=\"k\">class</span> <span class=\"nf\">SecureHost</span> <span class=\"p\">{</span>\n <span class=\"k\">async</span> <span class=\"nf\">callTool</span><span class=\"p\">(</span><span class=\"n\">name</span><span class=\"p\">,</span> <span class=\"n\">args</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"c\">// Host validates path before allowing tool execution</span>\n <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">args</span><span class=\"p\">.</span>path <span class=\"o\">&&</span> <span class=\"o\">!</span><span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">isWithinRoots</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"p\">.</span>path<span class=\"p\">)</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">throw</span> <span class=\"k\">new</span> <span class=\"nf\">Error</span><span class=\"p\">(</span><span class=\"s\">\"Access denied: outside declared roots\"</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"k\">return</span> <span class=\"k\">await</span> <span class=\"nb\">this</span><span class=\"p\">.</span><span class=\"nf\">mcpRequest</span><span class=\"p\">(</span><span class=\"s\">\"tools/call\"</span><span class=\"p\">,</span> <span class=\"p\">{</span> name<span class=\"p\">,</span> args <span class=\"p\">}</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n\n <span class=\"nf\">isWithinRoots</span><span class=\"p\">(</span><span class=\"n\">path</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"k\">return</span> <span class=\"nb\">this</span><span class=\"p\">.</span>roots<span class=\"p\">.</span><span class=\"nf\">some</span><span class=\"p\">(</span><span class=\"n\">root</span> <span class=\"o\">=></span> <span class=\"n\">path</span><span class=\"p\">.</span><span class=\"nf\">startsWith</span><span class=\"p\">(</span><span class=\"n\">root</span><span class=\"p\">)</span><span class=\"p\">)</span><span class=\"p\">;</span>\n <span class=\"p\">}</span>\n<span class=\"p\">}</span>\n</code></pre></div>\n<h2>Security Model</h2>\n<p><strong>Three layers</strong>:</p>\n<ol>\n<li><strong>Roots declaration</strong>: Client tells server allowed boundaries</li>\n<li><strong>Server cooperation</strong>: Server respects boundaries (trust-based)</li>\n<li><strong>Host enforcement</strong>: Host validates/sandboxes actual operations</li>\n</ol>\n<p><strong>Reality</strong>: A malicious MCP server can ignore roots and attempt filesystem access outside declared boundaries. The host OS permissions and host application sandboxing are the actual security barriers. <sup class=\"trigger\"><a href=\"https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices\" target=\"_blank\">1</a><span class=\"tooltip top center citation\"><a href=\"https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices#:~:text=This%20document,MCP-based%20systems.\"><span class=\"source\"><img alt=\"\" src=\"/proxy/favicons?c=lQ30-cxV_E2Vdyqb6hrbuYgId7qu7hecjO7o1T7aqQDFc7XpcLttL1Ryala-GNHJl7vE6eoyNoNEwrf5HFmvH4o0JWb6I_fOeoYXBGKd-mTBOLhUiSZ5XXj570SId1bh\"> modelcontextprotocol.io</span><b>1. Security Best Practices - Model Context Protocol</b></a><span class=\"passage\">This document provides security considerations for the Model Context Protocol (MCP), complementing the MCP Authorization specification. This document identifies security risks, attack vectors, and best practices specific to MCP implementations. The primary audience for this document includes developers implementing MCP authorization flows, MCP server operators, and security professionals evaluating MCP-based systems.</span></span></sup></p>\n<p>Roots are primarily for UX coordination—helping well-behaved servers understand their operating context, not preventing malicious behavior.</p>","md":"# Roots Enforcement\n\n**Roots are NOT enforced by MCP.** They're a coordination mechanism, not a security boundary. [^2][^3]\n\n## How It Works\n\n**Specification says**: Servers \"SHOULD respect\" roots [^3]\n\nThis means:\n- Roots are **advisory**, not mandatory\n- Servers are expected to honor them voluntarily\n- No protocol-level enforcement exists\n\n## Actual Enforcement\n\n**Host application responsibility**: [^1]\n\nThe host must implement security measures:\n\n```javascript\n// Host-level enforcement example\nclass SecureHost {\n async callTool(name, args) {\n // Host validates path before allowing tool execution\n if (args.path && !this.isWithinRoots(args.path)) {\n throw new Error(\"Access denied: outside declared roots\");\n }\n \n return await this.mcpRequest(\"tools/call\", { name, args });\n }\n \n isWithinRoots(path) {\n return this.roots.some(root => path.startsWith(root));\n }\n}\n```\n\n## Security Model\n\n**Three layers**:\n\n1. **Roots declaration**: Client tells server allowed boundaries\n2. **Server cooperation**: Server respects boundaries (trust-based)\n3. **Host enforcement**: Host validates/sandboxes actual operations\n\n**Reality**: A malicious MCP server can ignore roots and attempt filesystem access outside declared boundaries. The host OS permissions and host application sandboxing are the actual security barriers. [^1]\n\nRoots are primarily for UX coordination—helping well-behaved servers understand their operating context, not preventing malicious behavior.","profile":{"id":null,"name":null,"model":"claude-4-sonnet","model_name":"Claude 4.5 Sonnet","model_provider":"anthropic","model_input_limit":1000000,"recommended":false,"model_info":"\n\n<div class=\"heading\">\n <div class=\"left\">\n \n \n \n <svg class=\"model-icon icon-xs\" data-model=\"claude-4-sonnet\">\n <use href=\"#icon-anthropic\"/>\n </svg>\n <h3>\n \n <span class=\"model-provider\">Anthropic</span>\n \n <span class=\"model-name\">none</span>\n </h3>\n </div>\n\n \n <a href=\"/settings?p=custom_assistant&id=none\">\n <svg class=\"icon-sm edit-icon\" aria-hidden=\"true\">\n <use href=\"#icon-pencil\" />\n </svg>\n </a>\n \n</div>\n\n\n<hr />\n<ul>\n \n <li>\n <h4>\n Cost\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Relatively expensive\">\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-cost --medium\"></div>\n \n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-cost --medium\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Quality\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Speed\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 3 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li>\n <h4>\n Privacy\n </h4>\n <span>\n \n \n \n\n \n \n \n\n <div class=\"score\" aria-label=\"Rated 4 out of 5\">\n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"filled-bubble\"></div>\n \n \n \n \n <div aria-hidden=\"true\" class=\"unfilled-bubble\"></div>\n \n \n </div>\n</span>\n </li>\n <li class=\"divider\" aria-hidden=\"true\"></li>\n <li>\n <h4>Last updated</h4>\n <span class=\"date\">\n \n \n 2025-09-29\n \n \n </span>\n </li>\n \n</ul>\n","model_provider_name":"Anthropic","internet_access":true,"personalizations":true,"shortcut":null,"is_default_profile":false},"metadata":"<li>\n <span class=\"attribute\">Model</span>\n <span class=\"value\"><i class=\"icon-xs mr-2\"><svg><use href=\"#icon-anthropic\"></use></svg></i>Claude 4.5 Sonnet</span>\n</li>\n<li>\n <span class=\"attribute\">Version</span>\n <span class=\"value\">claude-sonnet-4-5-20250929</span>\n</li>\n<li>\n <span class=\"attribute\">Speed (tok/s)</span>\n <span class=\"value\">34</span>\n</li>\n<li>\n <span class=\"attribute\">Tokens</span>\n <span class=\"value\">8,625</span>\n</li>\n<li>\n <span class=\"attribute\">Cost / Total ($)</span>\n <span class=\"value\">0.05 / 0.48</span>\n</li>\n<li>\n <span class=\"attribute\">End to end time (s)</span>\n <span class=\"value\">19.58</span>\n</li>\n\n","documents":[]}]