One read of Model Context Protocolmcp-20261118T190716Z
54 pages moved out of 360 read.
Pages moved
54
significant first
Pages read
360
in this capture
Captured
19:07 UTC
Corpus hash
0806d60101ae
corpus-hash
What this read moved
1-25 of 54, page 1 of 3This capture is too large to show at once. Changes 1-25 of 54 are below, significant first; the rest are on the following screens.
docs/2026-07-28/develop/build-client Changed · +19 / -27 lines
from line 104
104104>
105105> load_dotenv() # load environment variables from .env
106106>
107> MODEL = "claude-opus-5"
107> MODEL = "claude-haiku-5-5"
108108> # The model thinks adaptively unless told otherwise, and max_tokens caps thinking
109109> # plus the reply, so leave room for both.
110110> MAX_TOKENS = 10000
from line 293
293293>
294294> ### 3. Query Processing
295295>
296> * Maintains conversation context
296> * Starts a new conversation for each query
297297> * Handles Claude's responses and tool calls
298298> * Runs every tool call of a turn, then answers them all in one message
299299> * Keeps looping while Claude asks for tools, up to `MAX_TOOL_TURNS`
from line 486
486486> {
487487> "type": "module",
488488> "scripts": {
489> "build": "tsc && chmod 755 build/index.js"
489> "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\""
490490> }
491491> }
492492> ```
from line 559
559559> throw new Error("ANTHROPIC_API_KEY is not set");
560560> }
561561>
562> const MODEL = "claude-opus-5";
562> const MODEL = "claude-haiku-5-5";
563563> // The model thinks adaptively unless told otherwise, and max_tokens caps
564564> // thinking plus the reply, so leave room for both.
565565> const MAX_TOKENS = 10000;
from line 779
779779> ```typescript theme={null}
780780> async function main() {
781781> if (process.argv.length < 3) {
782> console.log("Usage: node index.ts <path_to_server_script>");
782> console.log("Usage: node build/index.js <path_to_server_script>");
783783> return;
784784> }
785785> const mcpClient = new MCPClient();
from line 913
913913>
914914> * Java 17 or higher
915915> * Maven 3.6+
916> * npx package manager
916> * npm
917917> * Anthropic API key (Claude)
918918> * Brave Search API key
919919>
920920> ## Setting Up Your Environment
921921>
922> 1. Install npx (Node Package eXecute):
923> First, make sure to install [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
924> and then run:
922> 1. Install [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), which includes `npx`.
925923>
926> ```bash theme={null}
927> npm install -g npx
928> ```
929>
930924> 2. Clone the repository:
931925>
932926> ```bash theme={null}
from line 1182
11881182> First, let's create the basic client class:
11891183>
11901184> ```kotlin theme={null}
1191> private const val MODEL = "claude-opus-5"
1185> private const val MODEL = "claude-haiku-5-5"
11921186> // The model thinks adaptively unless told otherwise, and max_tokens caps thinking
11931187> // plus the reply, so leave room for both.
11941188> private const val MAX_TOKENS = 10_000L
from line 1555
15611555>
15621556> Before starting, ensure your system meets these requirements:
15631557>
1564> * .NET 8.0 or higher
1558> * .NET 10.0 or higher
15651559> * Anthropic API key (Claude)
15661560> * Windows, Linux, or macOS
15671561>
from line 1571
15771571> Then, add the required dependencies to your project:
15781572>
15791573> ```bash theme={null}
1580> dotnet add package ModelContextProtocol --prerelease
1581> dotnet add package Anthropic.SDK
1574> dotnet add package ModelContextProtocol
1575> dotnet add package Anthropic
15821576> dotnet add package Microsoft.Extensions.Hosting
15831577> dotnet add package Microsoft.Extensions.AI
15841578> ```
from line 1593
15991593> First, let's setup the basic client class in the file `Program.cs`:
16001594>
16011595> ```csharp theme={null}
1602> using Anthropic.SDK;
1596> using Anthropic;
16031597> using Microsoft.Extensions.AI;
16041598> using Microsoft.Extensions.Configuration;
16051599> using Microsoft.Extensions.Hosting;
from line 1651
16571651> Now let's add the core functionality for processing queries and handling tool calls:
16581652>
16591653> ```csharp theme={null}
1660> using var anthropicClient = new AnthropicClient(new APIAuthentication(builder.Configuration["ANTHROPIC_API_KEY"]))
1661> .Messages
1654> using var anthropicClient = new AnthropicClient(new() { ApiKey = builder.Configuration["ANTHROPIC_API_KEY"] })
1655> .AsIChatClient("claude-haiku-5-5")
16621656> .AsBuilder()
16631657> .UseFunctionInvocation()
16641658> .Build();
from line 1660
16661660> var options = new ChatOptions
16671661> {
16681662> MaxOutputTokens = 10000,
1669> ModelId = "claude-opus-5",
16701663> Tools = [.. tools]
16711664> };
16721665>
from line 1711
17181711>
17191712> * Leverages [Microsoft.Extensions.AI](https://learn.microsoft.com/dotnet/ai/ai-extensions) for the chat client.
17201713> * Configures the `IChatClient` to use automatic tool (function) invocation.
1721> * The client reads user input and sends it to the server.
1722> * The server processes the query and returns a response.
1723> * The response is displayed to the user.
1714> * The client reads user input and sends it to Claude.
1715> * When Claude asks for a tool, the client calls it on the server and sends the result back to Claude.
1716> * The client displays Claude's response to the user.
17241717>
17251718> ## Running the Client
17261719>
from line 1735
17421735> 2. List available tools
17431736> 3. Start an interactive chat session where you can:
17441737> * Enter queries
1745> * See tool executions
17461738> * Get responses from Claude
17471739> 4. Exit the session when done
17481740>
from line 1821
18291821> require "mcp"
18301822>
18311823> class MCPClient
1832> ANTHROPIC_MODEL = "claude-opus-5"
1824> ANTHROPIC_MODEL = "claude-haiku-5-5"
18331825> # The model thinks adaptively unless told otherwise, and max_tokens caps thinking
18341826> # plus the reply, so leave room for both.
18351827> MAX_TOKENS = 10000
from line 2268
22762268> use tokio::io::{self, AsyncBufReadExt, BufReader};
22772269> use tokio::process::Command;
22782270>
2279> const MODEL_ANTHROPIC: &str = "claude-opus-5";
2271> const MODEL_ANTHROPIC: &str = "claude-haiku-5-5";
22802272> /// The model may think before answering, and max_tokens caps thinking
22812273> /// plus the reply, so leave room for both.
22822274> const MAX_TOKENS: u32 = 10000;
docs/2026-07-28/develop/build-server Changed · +44 / -27 lines
from line 128
128128>
129129> import httpx2
130130> from mcp.server import MCPServer
131> from mcp.server.mcpserver.exceptions import ToolError
131132>
132133> # Initialize MCPServer
133134> mcp = MCPServer("weather")
from line 150
149150> async def make_nws_request(url: str) -> dict[str, Any] | None:
150151> """Make a request to the NWS API with proper error handling."""
151152> headers = {"User-Agent": USER_AGENT, "Accept": "application/geo+json"}
152> async with httpx2.AsyncClient() as client:
153> async with httpx2.AsyncClient(follow_redirects=True) as client:
153154> try:
154155> response = await client.get(url, headers=headers, timeout=30.0)
155156> response.raise_for_status()
from line 183
182183> Args:
183184> state: Two-letter US state code (e.g. CA, NY)
184185> """
185> url = f"{NWS_API_BASE}/alerts/active/area/{state}"
186> url = f"{NWS_API_BASE}/alerts/active/area/{state.upper()}"
186187> data = await make_nws_request(url)
187188>
188189> if not data or "features" not in data:
189> return "Unable to fetch alerts or no alerts found."
190> raise ToolError("Unable to fetch alerts.")
190191>
191192> if not data["features"]:
192193> return "No active alerts for this state."
from line 209
208209> points_data = await make_nws_request(points_url)
209210>
210211> if not points_data:
211> return "Unable to fetch forecast data for this location."
212> raise ToolError("Unable to fetch forecast data for this location.")
212213>
213214> # Get the forecast URL from the points response
214215> forecast_url = points_data["properties"]["forecast"]
from line 216
215216> forecast_data = await make_nws_request(forecast_url)
216217>
217218> if not forecast_data:
218> return "Unable to fetch detailed forecast."
219> raise ToolError("Unable to fetch detailed forecast.")
219220>
220221> # Format the periods into a readable forecast
221222> periods = forecast_data["properties"]["periods"]
223> if not periods:
224> raise ToolError("No forecast periods available.")
225>
222226> forecasts = []
223227> for period in periods[:5]: # Only show next 5 periods
224228> forecast = f"""
from line 415
411415> "weather": "./build/index.js"
412416> },
413417> "scripts": {
414> "build": "tsc && chmod 755 build/index.js"
418> "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\""
415419> },
416420> "files": ["build"]
417421> }
from line 558
554558> },
555559> async ({ state }) => {
556560> const stateCode = state.toUpperCase();
557> const alertsUrl = `${NWS_API_BASE}/alerts?area=${stateCode}`;
561> const alertsUrl = `${NWS_API_BASE}/alerts/active?area=${stateCode}`;
558562> const alertsData = await makeNWSRequest<AlertsResponse>(alertsUrl);
559563>
560564> if (!alertsData) {
from line 569
565569> text: "Failed to retrieve alerts data",
566570> },
567571> ],
572> isError: true,
568573> };
569574> }
570575>
from line 629
624629> text: `Failed to retrieve grid point data for coordinates: ${latitude}, ${longitude}. This location may not be supported by the NWS API (only US locations are supported).`,
625630> },
626631> ],
632> isError: true,
627633> };
628634> }
629635>
from line 642
636642> text: "Failed to get forecast URL from grid point data",
637643> },
638644> ],
645> isError: true,
639646> };
640647> }
641648>
from line 656
649656> text: "Failed to retrieve forecast data",
650657> },
651658> ],
659> isError: true,
652660> };
653661> }
654662>
from line 669
661669> text: "No forecast periods available",
662670> },
663671> ],
672> isError: true,
664673> };
665674> }
666675>
from line 677
668677> const formattedForecast = periods.map((period: ForecastPeriod) =>
669678> [
670679> `${period.name || "Unknown"}:`,
671> `Temperature: ${period.temperature || "Unknown"}°${period.temperatureUnit || "F"}`,
680> `Temperature: ${period.temperature ?? "Unknown"}°${period.temperatureUnit || "F"}`,
672681> `Wind: ${period.windSpeed || "Unknown"} ${period.windDirection || ""}`,
673682> `${period.shortForecast || "No forecast available"}`,
674683> "---",
from line 837
828837>
829838> ```groovy Gradle theme={null}
830839> dependencies {
831> implementation platform("org.springframework.ai:spring-ai-starter-mcp-server")
832> implementation platform("org.springframework:spring-web")
840> implementation "org.springframework.ai:spring-ai-starter-mcp-server"
841> implementation "org.springframework:spring-web"
833842> }
834843> ```
835844>
from line 931
922931> }
923932> ```
924933>
925> Uses the `MethodToolCallbackProvider` utils to convert the `@Tools` into actionable callbacks used by the MCP server.
934> Uses the `MethodToolCallbackProvider` utils to convert the `@Tool` methods into actionable callbacks used by the MCP server.
926935>
927936> ### Running the server
928937>
from line 994
985994> "spring-ai-mcp-weather": {
986995> "command": "java",
987996> "args": [
988> "-Dspring.ai.mcp.server.transport=STDIO",
997> "-Dspring.ai.mcp.server.stdio=true",
989998> "-jar",
990> "C:\\ABSOLUTE\\PATH\\TO\\PARENT\\FOLDER\\weather\\mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar"
999> "C:\\ABSOLUTE\\PATH\\TO\\PARENT\\FOLDER\\mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar"
9911000> ]
9921001> }
9931002> }
from line 1009
10001009>
10011010> This tells Claude for Desktop:
10021011>
1003> 1. There's an MCP server named "my-weather-server"
1004> 2. To launch it by running `java -jar /ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar`
1012> 1. There's an MCP server named "spring-ai-mcp-weather"
1013> 2. To launch it by running `java -Dspring.ai.mcp.server.stdio=true -jar /ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar`
10051014>
10061015> Save the file, and restart **Claude for Desktop**.
10071016>
from line 1022
10131022>
10141023> ```java theme={null}
10151024> var stdioParams = ServerParameters.builder("java")
1016> .args("-jar", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar")
1025> .args("-Dspring.ai.mcp.server.stdio=true", "-jar", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar")
10171026> .build();
10181027>
10191028> var stdioTransport = new StdioClientTransport(stdioParams, McpJsonDefaults.getMapper());
from line 1035
10261035>
10271036> CallToolResult weather = mcpClient.callTool(
10281037> new CallToolRequest("getWeatherForecastByLocation",
1029> Map.of("latitude", "47.6062", "longitude", "-122.3321")));
1038> Map.of("latitude", 47.6062, "longitude", -122.3321)));
10301039>
10311040> CallToolResult alert = mcpClient.callTool(
10321041> new CallToolRequest("getAlerts", Map.of("state", "NY")));
from line 1233
12241233>
12251234> // Extension function to fetch weather alerts for a given state
12261235> suspend fun HttpClient.getAlerts(state: String): List<String> {
1227> val alerts = this.get("/alerts/active/area/$state").body<AlertsResponse>()
1236> val alerts = this.get("/alerts/active/area/${state.uppercase()}").body<AlertsResponse>()
12281237> return alerts.features.map { feature ->
12291238> """
12301239> Event: ${feature.properties.event}
from line 1321
13121321> val state = request.arguments?.get("state")?.jsonPrimitive?.content
13131322> ?: return@addTool CallToolResult(
13141323> content = listOf(TextContent("The 'state' parameter is required.")),
1324> isError = true,
13151325> )
13161326>
13171327> val alerts = httpClient.getAlerts(state)
from line 1350
13401350> if (latitude == null || longitude == null) {
13411351> return@addTool CallToolResult(
13421352> content = listOf(TextContent("The 'latitude' and 'longitude' parameters are required.")),
1353> isError = true,
13431354> )
13441355> }
13451356>
from line 1455
14441455>
14451456> * C#
14461457> * LLMs like Claude
1447> * .NET 8 or higher
1458> * .NET 10 or higher
14481459>
14491460> ### Logging in MCP Servers
14501461>
from line 1471
14601471>
14611472> ### System requirements
14621473>
1463> * [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) or higher installed.
1474> * [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) or higher installed.
14641475>
14651476> ### Set up your environment
14661477>
from line 1506
14951506>
14961507> ```bash theme={null}
14971508> # Add the Model Context Protocol SDK NuGet package
1498> dotnet add package ModelContextProtocol --prerelease
1509> dotnet add package ModelContextProtocol
14991510> # Add the .NET Hosting NuGet package
15001511> dotnet add package Microsoft.Extensions.Hosting
15011512> ```
from line 1583
15721583> HttpClient client,
15731584> [Description("The US state code to get alerts for.")] string state)
15741585> {
1575> using var jsonDocument = await client.ReadJsonDocumentAsync($"/alerts/active/area/{state}");
1586> using var jsonDocument = await client.ReadJsonDocumentAsync($"/alerts/active/area/{state.ToUpperInvariant()}");
15761587> var jsonElement = jsonDocument.RootElement;
15771588> var alerts = jsonElement.GetProperty("features").EnumerateArray();
15781589>
from line 1691
16801691> This tells Claude for Desktop:
16811692>
16821693> 1. There's an MCP server named "weather"
1683> 2. Launch it by running `dotnet run /ABSOLUTE/PATH/TO/PROJECT`
1684> Save the file, and restart **Claude for Desktop**.
1694> 2. To launch it by running `dotnet run --project /ABSOLUTE/PATH/TO/PROJECT --no-build`
1695>
1696> Save the file, and restart **Claude for Desktop**.
16851697
16861698> [tab] Ruby
16871699>
from line 2427
24152427> }
24162428> ```
24172429>
2418> `get_info` returns a `ServerConfig`. Setting `server_info` gives the server its own name and version in the `initialize` response.
2430> `get_info` returns a `ServerConfig`. Setting `server_info` makes the server report its own name and version instead of those of the `rmcp` crate.
24192431>
24202432> ### Running the server
24212433>
from line 2750
27382750> Content: []mcp.Content{
27392751> &mcp.TextContent{Text: "Unable to fetch forecast data for this location."},
27402752> },
2753> IsError: true,
27412754> }, nil, nil
27422755> }
27432756>
from line 2761
27482761> Content: []mcp.Content{
27492762> &mcp.TextContent{Text: "Unable to fetch forecast URL."},
27502763> },
2764> IsError: true,
27512765> }, nil, nil
27522766> }
27532767>
from line 2771
27572771> Content: []mcp.Content{
27582772> &mcp.TextContent{Text: "Unable to fetch detailed forecast."},
27592773> },
2774> IsError: true,
27602775> }, nil, nil
27612776> }
27622777>
from line 2782
27672782> Content: []mcp.Content{
27682783> &mcp.TextContent{Text: "No forecast periods available."},
27692784> },
2785> IsError: true,
27702786> }, nil, nil
27712787> }
27722788>
from line 2812
27962812> if err != nil {
27972813> return &mcp.CallToolResult{
27982814> Content: []mcp.Content{
2799> &mcp.TextContent{Text: "Unable to fetch alerts or no alerts found."},
2815> &mcp.TextContent{Text: "Unable to fetch alerts."},
28002816> },
2817> IsError: true,
28012818> }, nil, nil
28022819> }
28032820>
from line 2945
29282945
29292946
29302947
2931After clicking on the plus icon, hover over the "Connectors" menu. You should see the `weather` servers listed:
2948After clicking on the plus icon, hover over the "Connectors" menu. You should see your weather server listed:
29322949
29332950
29342951
docs/2026-07-28/develop/connect-local-servers Changed · +16 / -11 lines
from line 198
198198> ```
199199>
200200> ```powershell Windows theme={null}
201> type "%APPDATA%\Claude\logs\mcp*.log"
201> type "$env:AppData\Claude\logs\mcp*.log"
202202> ```
203203
204204> [accordion] Tool calls failing silently
from line 219
219219>
220220> ```json theme={null}
221221> {
222> "brave-search": {
223> "command": "npx",
224> "args": ["-y", "@modelcontextprotocol/server-brave-search"],
225> "env": {
226> "APPDATA": "C:\\Users\\user\\AppData\\Roaming\\",
227> "BRAVE_API_KEY": "..."
222> "mcpServers": {
223> "filesystem": {
224> "command": "npx",
225> "args": [
226> "-y",
227> "@modelcontextprotocol/server-filesystem",
228> "C:\\Users\\username\\Desktop",
229> "C:\\Users\\username\\Downloads"
230> ],
231> "env": {
232> "APPDATA": "C:\\Users\\username\\AppData\\Roaming"
233> }
228234> }
229235> }
230236> }
from line 252
246252
247253Now that you've successfully connected Claude Desktop to a local MCP server, explore these options to expand your setup:
248254
249> [card] [Explore other servers](https://github.com/modelcontextprotocol/servers)
255> [card] [Explore other servers](https://registry.modelcontextprotocol.io/)
250256>
251> Browse our collection of official and community-created MCP servers for
252> additional capabilities
257> Browse the servers published to the MCP Registry
253258
254259> [card] [Build your own server](https://modelcontextprotocol.io/docs/2026-07-28/develop/build-server.md)
255260>
docs/2026-07-28/tutorials/security/local-server-security Changed · +3 / -3 lines
from line 3
33> Practical defaults for running MCP servers safely on your own machine.
44
55Most MCP security documentation covers the protocol threat model: OAuth flows,
6token handling, session hijacking, and confused deputy attacks. For those, see
6token handling, state handle hijacking, and confused deputy attacks. For those, see
77[Authorization](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization.md) and
88[Security Best Practices](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices.md).
99
from line 421
421421
422422> [card] [Security Best Practices](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/security_best_practices.md)
423423>
424> The protocol threat model: confused deputy, token passthrough, and session
425> hijacking
424> The protocol threat model: confused deputy, token passthrough, and state
425> handle hijacking
426426
427427> [card] [Authorization](https://modelcontextprotocol.io/docs/2026-07-28/tutorials/security/authorization.md)
428428>
docs/draft/develop/build-client Changed · +19 / -27 lines
from line 104
104104>
105105> load_dotenv() # load environment variables from .env
106106>
107> MODEL = "claude-opus-5"
107> MODEL = "claude-haiku-5-5"
108108> # The model thinks adaptively unless told otherwise, and max_tokens caps thinking
109109> # plus the reply, so leave room for both.
110110> MAX_TOKENS = 10000
from line 293
293293>
294294> ### 3. Query Processing
295295>
296> * Maintains conversation context
296> * Starts a new conversation for each query
297297> * Handles Claude's responses and tool calls
298298> * Runs every tool call of a turn, then answers them all in one message
299299> * Keeps looping while Claude asks for tools, up to `MAX_TOOL_TURNS`
from line 486
486486> {
487487> "type": "module",
488488> "scripts": {
489> "build": "tsc && chmod 755 build/index.js"
489> "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\""
490490> }
491491> }
492492> ```
from line 559
559559> throw new Error("ANTHROPIC_API_KEY is not set");
560560> }
561561>
562> const MODEL = "claude-opus-5";
562> const MODEL = "claude-haiku-5-5";
563563> // The model thinks adaptively unless told otherwise, and max_tokens caps
564564> // thinking plus the reply, so leave room for both.
565565> const MAX_TOKENS = 10000;
from line 779
779779> ```typescript theme={null}
780780> async function main() {
781781> if (process.argv.length < 3) {
782> console.log("Usage: node index.ts <path_to_server_script>");
782> console.log("Usage: node build/index.js <path_to_server_script>");
783783> return;
784784> }
785785> const mcpClient = new MCPClient();
from line 913
913913>
914914> * Java 17 or higher
915915> * Maven 3.6+
916> * npx package manager
916> * npm
917917> * Anthropic API key (Claude)
918918> * Brave Search API key
919919>
920920> ## Setting Up Your Environment
921921>
922> 1. Install npx (Node Package eXecute):
923> First, make sure to install [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm)
924> and then run:
922> 1. Install [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), which includes `npx`.
925923>
926> ```bash theme={null}
927> npm install -g npx
928> ```
929>
930924> 2. Clone the repository:
931925>
932926> ```bash theme={null}
from line 1182
11881182> First, let's create the basic client class:
11891183>
11901184> ```kotlin theme={null}
1191> private const val MODEL = "claude-opus-5"
1185> private const val MODEL = "claude-haiku-5-5"
11921186> // The model thinks adaptively unless told otherwise, and max_tokens caps thinking
11931187> // plus the reply, so leave room for both.
11941188> private const val MAX_TOKENS = 10_000L
from line 1555
15611555>
15621556> Before starting, ensure your system meets these requirements:
15631557>
1564> * .NET 8.0 or higher
1558> * .NET 10.0 or higher
15651559> * Anthropic API key (Claude)
15661560> * Windows, Linux, or macOS
15671561>
from line 1571
15771571> Then, add the required dependencies to your project:
15781572>
15791573> ```bash theme={null}
1580> dotnet add package ModelContextProtocol --prerelease
1581> dotnet add package Anthropic.SDK
1574> dotnet add package ModelContextProtocol
1575> dotnet add package Anthropic
15821576> dotnet add package Microsoft.Extensions.Hosting
15831577> dotnet add package Microsoft.Extensions.AI
15841578> ```
from line 1593
15991593> First, let's setup the basic client class in the file `Program.cs`:
16001594>
16011595> ```csharp theme={null}
1602> using Anthropic.SDK;
1596> using Anthropic;
16031597> using Microsoft.Extensions.AI;
16041598> using Microsoft.Extensions.Configuration;
16051599> using Microsoft.Extensions.Hosting;
from line 1651
16571651> Now let's add the core functionality for processing queries and handling tool calls:
16581652>
16591653> ```csharp theme={null}
1660> using var anthropicClient = new AnthropicClient(new APIAuthentication(builder.Configuration["ANTHROPIC_API_KEY"]))
1661> .Messages
1654> using var anthropicClient = new AnthropicClient(new() { ApiKey = builder.Configuration["ANTHROPIC_API_KEY"] })
1655> .AsIChatClient("claude-haiku-5-5")
16621656> .AsBuilder()
16631657> .UseFunctionInvocation()
16641658> .Build();
from line 1660
16661660> var options = new ChatOptions
16671661> {
16681662> MaxOutputTokens = 10000,
1669> ModelId = "claude-opus-5",
16701663> Tools = [.. tools]
16711664> };
16721665>
from line 1711
17181711>
17191712> * Leverages [Microsoft.Extensions.AI](https://learn.microsoft.com/dotnet/ai/ai-extensions) for the chat client.
17201713> * Configures the `IChatClient` to use automatic tool (function) invocation.
1721> * The client reads user input and sends it to the server.
1722> * The server processes the query and returns a response.
1723> * The response is displayed to the user.
1714> * The client reads user input and sends it to Claude.
1715> * When Claude asks for a tool, the client calls it on the server and sends the result back to Claude.
1716> * The client displays Claude's response to the user.
17241717>
17251718> ## Running the Client
17261719>
from line 1735
17421735> 2. List available tools
17431736> 3. Start an interactive chat session where you can:
17441737> * Enter queries
1745> * See tool executions
17461738> * Get responses from Claude
17471739> 4. Exit the session when done
17481740>
from line 1821
18291821> require "mcp"
18301822>
18311823> class MCPClient
1832> ANTHROPIC_MODEL = "claude-opus-5"
1824> ANTHROPIC_MODEL = "claude-haiku-5-5"
18331825> # The model thinks adaptively unless told otherwise, and max_tokens caps thinking
18341826> # plus the reply, so leave room for both.
18351827> MAX_TOKENS = 10000
from line 2268
22762268> use tokio::io::{self, AsyncBufReadExt, BufReader};
22772269> use tokio::process::Command;
22782270>
2279> const MODEL_ANTHROPIC: &str = "claude-opus-5";
2271> const MODEL_ANTHROPIC: &str = "claude-haiku-5-5";
22802272> /// The model may think before answering, and max_tokens caps thinking
22812273> /// plus the reply, so leave room for both.
22822274> const MAX_TOKENS: u32 = 10000;
docs/draft/develop/build-server Changed · +44 / -27 lines
from line 128
128128>
129129> import httpx2
130130> from mcp.server import MCPServer
131> from mcp.server.mcpserver.exceptions import ToolError
131132>
132133> # Initialize MCPServer
133134> mcp = MCPServer("weather")
from line 150
149150> async def make_nws_request(url: str) -> dict[str, Any] | None:
150151> """Make a request to the NWS API with proper error handling."""
151152> headers = {"User-Agent": USER_AGENT, "Accept": "application/geo+json"}
152> async with httpx2.AsyncClient() as client:
153> async with httpx2.AsyncClient(follow_redirects=True) as client:
153154> try:
154155> response = await client.get(url, headers=headers, timeout=30.0)
155156> response.raise_for_status()
from line 183
182183> Args:
183184> state: Two-letter US state code (e.g. CA, NY)
184185> """
185> url = f"{NWS_API_BASE}/alerts/active/area/{state}"
186> url = f"{NWS_API_BASE}/alerts/active/area/{state.upper()}"
186187> data = await make_nws_request(url)
187188>
188189> if not data or "features" not in data:
189> return "Unable to fetch alerts or no alerts found."
190> raise ToolError("Unable to fetch alerts.")
190191>
191192> if not data["features"]:
192193> return "No active alerts for this state."
from line 209
208209> points_data = await make_nws_request(points_url)
209210>
210211> if not points_data:
211> return "Unable to fetch forecast data for this location."
212> raise ToolError("Unable to fetch forecast data for this location.")
212213>
213214> # Get the forecast URL from the points response
214215> forecast_url = points_data["properties"]["forecast"]
from line 216
215216> forecast_data = await make_nws_request(forecast_url)
216217>
217218> if not forecast_data:
218> return "Unable to fetch detailed forecast."
219> raise ToolError("Unable to fetch detailed forecast.")
219220>
220221> # Format the periods into a readable forecast
221222> periods = forecast_data["properties"]["periods"]
223> if not periods:
224> raise ToolError("No forecast periods available.")
225>
222226> forecasts = []
223227> for period in periods[:5]: # Only show next 5 periods
224228> forecast = f"""
from line 415
411415> "weather": "./build/index.js"
412416> },
413417> "scripts": {
414> "build": "tsc && chmod 755 build/index.js"
418> "build": "tsc && node -e \"require('fs').chmodSync('build/index.js', '755')\""
415419> },
416420> "files": ["build"]
417421> }
from line 558
554558> },
555559> async ({ state }) => {
556560> const stateCode = state.toUpperCase();
557> const alertsUrl = `${NWS_API_BASE}/alerts?area=${stateCode}`;
561> const alertsUrl = `${NWS_API_BASE}/alerts/active?area=${stateCode}`;
558562> const alertsData = await makeNWSRequest<AlertsResponse>(alertsUrl);
559563>
560564> if (!alertsData) {
from line 569
565569> text: "Failed to retrieve alerts data",
566570> },
567571> ],
572> isError: true,
568573> };
569574> }
570575>
from line 629
624629> text: `Failed to retrieve grid point data for coordinates: ${latitude}, ${longitude}. This location may not be supported by the NWS API (only US locations are supported).`,
625630> },
626631> ],
632> isError: true,
627633> };
628634> }
629635>
from line 642
636642> text: "Failed to get forecast URL from grid point data",
637643> },
638644> ],
645> isError: true,
639646> };
640647> }
641648>
from line 656
649656> text: "Failed to retrieve forecast data",
650657> },
651658> ],
659> isError: true,
652660> };
653661> }
654662>
from line 669
661669> text: "No forecast periods available",
662670> },
663671> ],
672> isError: true,
664673> };
665674> }
666675>
from line 677
668677> const formattedForecast = periods.map((period: ForecastPeriod) =>
669678> [
670679> `${period.name || "Unknown"}:`,
671> `Temperature: ${period.temperature || "Unknown"}°${period.temperatureUnit || "F"}`,
680> `Temperature: ${period.temperature ?? "Unknown"}°${period.temperatureUnit || "F"}`,
672681> `Wind: ${period.windSpeed || "Unknown"} ${period.windDirection || ""}`,
673682> `${period.shortForecast || "No forecast available"}`,
674683> "---",
from line 837
828837>
829838> ```groovy Gradle theme={null}
830839> dependencies {
831> implementation platform("org.springframework.ai:spring-ai-starter-mcp-server")
832> implementation platform("org.springframework:spring-web")
840> implementation "org.springframework.ai:spring-ai-starter-mcp-server"
841> implementation "org.springframework:spring-web"
833842> }
834843> ```
835844>
from line 931
922931> }
923932> ```
924933>
925> Uses the `MethodToolCallbackProvider` utils to convert the `@Tools` into actionable callbacks used by the MCP server.
934> Uses the `MethodToolCallbackProvider` utils to convert the `@Tool` methods into actionable callbacks used by the MCP server.
926935>
927936> ### Running the server
928937>
from line 994
985994> "spring-ai-mcp-weather": {
986995> "command": "java",
987996> "args": [
988> "-Dspring.ai.mcp.server.transport=STDIO",
997> "-Dspring.ai.mcp.server.stdio=true",
989998> "-jar",
990> "C:\\ABSOLUTE\\PATH\\TO\\PARENT\\FOLDER\\weather\\mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar"
999> "C:\\ABSOLUTE\\PATH\\TO\\PARENT\\FOLDER\\mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar"
9911000> ]
9921001> }
9931002> }
from line 1009
10001009>
10011010> This tells Claude for Desktop:
10021011>
1003> 1. There's an MCP server named "my-weather-server"
1004> 2. To launch it by running `java -jar /ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar`
1012> 1. There's an MCP server named "spring-ai-mcp-weather"
1013> 2. To launch it by running `java -Dspring.ai.mcp.server.stdio=true -jar /ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar`
10051014>
10061015> Save the file, and restart **Claude for Desktop**.
10071016>
from line 1022
10131022>
10141023> ```java theme={null}
10151024> var stdioParams = ServerParameters.builder("java")
1016> .args("-jar", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar")
1025> .args("-Dspring.ai.mcp.server.stdio=true", "-jar", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar")
10171026> .build();
10181027>
10191028> var stdioTransport = new StdioClientTransport(stdioParams, McpJsonDefaults.getMapper());
from line 1035
10261035>
10271036> CallToolResult weather = mcpClient.callTool(
10281037> new CallToolRequest("getWeatherForecastByLocation",
1029> Map.of("latitude", "47.6062", "longitude", "-122.3321")));
1038> Map.of("latitude", 47.6062, "longitude", -122.3321)));
10301039>
10311040> CallToolResult alert = mcpClient.callTool(
10321041> new CallToolRequest("getAlerts", Map.of("state", "NY")));
from line 1233
12241233>
12251234> // Extension function to fetch weather alerts for a given state
12261235> suspend fun HttpClient.getAlerts(state: String): List<String> {
1227> val alerts = this.get("/alerts/active/area/$state").body<AlertsResponse>()
1236> val alerts = this.get("/alerts/active/area/${state.uppercase()}").body<AlertsResponse>()
12281237> return alerts.features.map { feature ->
12291238> """
12301239> Event: ${feature.properties.event}
from line 1321
13121321> val state = request.arguments?.get("state")?.jsonPrimitive?.content
13131322> ?: return@addTool CallToolResult(
13141323> content = listOf(TextContent("The 'state' parameter is required.")),
1324> isError = true,
13151325> )
13161326>
13171327> val alerts = httpClient.getAlerts(state)
from line 1350
13401350> if (latitude == null || longitude == null) {
13411351> return@addTool CallToolResult(
13421352> content = listOf(TextContent("The 'latitude' and 'longitude' parameters are required.")),
1353> isError = true,
13431354> )
13441355> }
13451356>
from line 1455
14441455>
14451456> * C#
14461457> * LLMs like Claude
1447> * .NET 8 or higher
1458> * .NET 10 or higher
14481459>
14491460> ### Logging in MCP Servers
14501461>
from line 1471
14601471>
14611472> ### System requirements
14621473>
1463> * [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) or higher installed.
1474> * [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0) or higher installed.
14641475>
14651476> ### Set up your environment
14661477>
from line 1506
14951506>
14961507> ```bash theme={null}
14971508> # Add the Model Context Protocol SDK NuGet package
1498> dotnet add package ModelContextProtocol --prerelease
1509> dotnet add package ModelContextProtocol
14991510> # Add the .NET Hosting NuGet package
15001511> dotnet add package Microsoft.Extensions.Hosting
15011512> ```
from line 1583
15721583> HttpClient client,
15731584> [Description("The US state code to get alerts for.")] string state)
15741585> {
1575> using var jsonDocument = await client.ReadJsonDocumentAsync($"/alerts/active/area/{state}");
1586> using var jsonDocument = await client.ReadJsonDocumentAsync($"/alerts/active/area/{state.ToUpperInvariant()}");
15761587> var jsonElement = jsonDocument.RootElement;
15771588> var alerts = jsonElement.GetProperty("features").EnumerateArray();
15781589>
from line 1691
16801691> This tells Claude for Desktop:
16811692>
16821693> 1. There's an MCP server named "weather"
1683> 2. Launch it by running `dotnet run /ABSOLUTE/PATH/TO/PROJECT`
1684> Save the file, and restart **Claude for Desktop**.
1694> 2. To launch it by running `dotnet run --project /ABSOLUTE/PATH/TO/PROJECT --no-build`
1695>
1696> Save the file, and restart **Claude for Desktop**.
16851697
16861698> [tab] Ruby
16871699>
from line 2427
24152427> }
24162428> ```
24172429>
2418> `get_info` returns a `ServerConfig`. Setting `server_info` gives the server its own name and version in the `initialize` response.
2430> `get_info` returns a `ServerConfig`. Setting `server_info` makes the server report its own name and version instead of those of the `rmcp` crate.
24192431>
24202432> ### Running the server
24212433>
from line 2750
27382750> Content: []mcp.Content{
27392751> &mcp.TextContent{Text: "Unable to fetch forecast data for this location."},
27402752> },
2753> IsError: true,
27412754> }, nil, nil
27422755> }
27432756>
from line 2761
27482761> Content: []mcp.Content{
27492762> &mcp.TextContent{Text: "Unable to fetch forecast URL."},
27502763> },
2764> IsError: true,
27512765> }, nil, nil
27522766> }
27532767>
from line 2771
27572771> Content: []mcp.Content{
27582772> &mcp.TextContent{Text: "Unable to fetch detailed forecast."},
27592773> },
2774> IsError: true,
27602775> }, nil, nil
27612776> }
27622777>
from line 2782
27672782> Content: []mcp.Content{
27682783> &mcp.TextContent{Text: "No forecast periods available."},
27692784> },
2785> IsError: true,
27702786> }, nil, nil
27712787> }
27722788>
from line 2812
27962812> if err != nil {
27972813> return &mcp.CallToolResult{
27982814> Content: []mcp.Content{
2799> &mcp.TextContent{Text: "Unable to fetch alerts or no alerts found."},
2815> &mcp.TextContent{Text: "Unable to fetch alerts."},
28002816> },
2817> IsError: true,
28012818> }, nil, nil
28022819> }
28032820>
from line 2945
29282945
29292946
29302947
2931After clicking on the plus icon, hover over the "Connectors" menu. You should see the `weather` servers listed:
2948After clicking on the plus icon, hover over the "Connectors" menu. You should see your weather server listed:
29322949
29332950
29342951
docs/draft/develop/connect-local-servers Changed · +16 / -11 lines
from line 198
198198> ```
199199>
200200> ```powershell Windows theme={null}
201> type "%APPDATA%\Claude\logs\mcp*.log"
201> type "$env:AppData\Claude\logs\mcp*.log"
202202> ```
203203
204204> [accordion] Tool calls failing silently
from line 219
219219>
220220> ```json theme={null}
221221> {
222> "brave-search": {
223> "command": "npx",
224> "args": ["-y", "@modelcontextprotocol/server-brave-search"],
225> "env": {
226> "APPDATA": "C:\\Users\\user\\AppData\\Roaming\\",
227> "BRAVE_API_KEY": "..."
222> "mcpServers": {
223> "filesystem": {
224> "command": "npx",
225> "args": [
226> "-y",
227> "@modelcontextprotocol/server-filesystem",
228> "C:\\Users\\username\\Desktop",
229> "C:\\Users\\username\\Downloads"
230> ],
231> "env": {
232> "APPDATA": "C:\\Users\\username\\AppData\\Roaming"
233> }
228234> }
229235> }
230236> }
from line 252
246252
247253Now that you've successfully connected Claude Desktop to a local MCP server, explore these options to expand your setup:
248254
249> [card] [Explore other servers](https://github.com/modelcontextprotocol/servers)
255> [card] [Explore other servers](https://registry.modelcontextprotocol.io/)
250256>
251> Browse our collection of official and community-created MCP servers for
252> additional capabilities
257> Browse the servers published to the MCP Registry
253258
254259> [card] [Build your own server](https://modelcontextprotocol.io/docs/draft/develop/build-server.md)
255260>
docs/draft/tutorials/security/local-server-security Changed · +3 / -3 lines
from line 3
33> Practical defaults for running MCP servers safely on your own machine.
44
55Most MCP security documentation covers the protocol threat model: OAuth flows,
6token handling, session hijacking, and confused deputy attacks. For those, see
6token handling, state handle hijacking, and confused deputy attacks. For those, see
77[Authorization](https://modelcontextprotocol.io/docs/draft/tutorials/security/authorization.md) and
88[Security Best Practices](https://modelcontextprotocol.io/docs/draft/tutorials/security/security_best_practices.md).
99
from line 421
421421
422422> [card] [Security Best Practices](https://modelcontextprotocol.io/docs/draft/tutorials/security/security_best_practices.md)
423423>
424> The protocol threat model: confused deputy, token passthrough, and session
425> hijacking
424> The protocol threat model: confused deputy, token passthrough, and state
425> handle hijacking
426426
427427> [card] [Authorization](https://modelcontextprotocol.io/docs/draft/tutorials/security/authorization.md)
428428>
specification/2026-07-28/basic/index Changed · +8 / -1 lines
from line 96
9696}
9797```
9898
99* Error responses **MUST** include the same ID as the request they correspond to (except in error cases where the ID could not be read due a malformed request).
99* Error responses **MUST** include the same ID as the request they correspond to (except in error cases where the ID could not be read due to a malformed request).
100100* Error responses **MUST** include an `error` field with a `code` and `message`.
101101* Error codes **MUST** be integers.
102102* Error responses **MAY** include a `data` member with additional information of any type, such
from line 350
350350| `io.modelcontextprotocol/clientInfo` | Client name and version | Per-request protocol fields (below) |
351351| `io.modelcontextprotocol/clientCapabilities` | Client capabilities relevant to a request | Per-request protocol fields (below) |
352352| `io.modelcontextprotocol/logLevel` | Minimum log level the server should emit for a request | [Logging](https://modelcontextprotocol.io/specification/2026-07-28/server/utilities/logging.md) |
353| `io.modelcontextprotocol/serverInfo` | Server name and version | Per-response protocol fields (below) |
353354| `io.modelcontextprotocol/subscriptionId` | Correlates a notification with its originating subscription | [Subscriptions](https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/subscriptions.md) |
354355| `traceparent`, `tracestate`, `baggage` | OpenTelemetry trace context propagation | OpenTelemetry trace context (below) |
355356
from line 437
436437 "location": "New York"
437438 },
438439 "_meta": {
440 "io.modelcontextprotocol/protocolVersion": "2026-07-28",
441 "io.modelcontextprotocol/clientInfo": {
442 "name": "ExampleClient",
443 "version": "1.0.0"
444 },
445 "io.modelcontextprotocol/clientCapabilities": {},
439446 "traceparent": "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01"
440447 }
441448 }
specification/2026-07-28/basic/transports/streamable-http Changed · +6 / -0 lines
from line 295
295295
296296```http theme={null}
297297POST /mcp HTTP/1.1
298Host: example.com
298299Content-Type: application/json
300Accept: application/json, text/event-stream
299301MCP-Protocol-Version: 2026-07-28
300302Mcp-Method: tools/call
301303Mcp-Name: get_weather
from line 327
325327
326328```http theme={null}
327329POST /mcp HTTP/1.1
330Host: example.com
328331Content-Type: application/json
332Accept: application/json, text/event-stream
329333MCP-Protocol-Version: 2026-07-28
330334Mcp-Method: resources/read
331335Mcp-Name: file:///projects/myapp/config.json
from line 435
431435
432436```http theme={null}
433437POST /mcp HTTP/1.1
438Host: example.com
434439Content-Type: application/json
440Accept: application/json, text/event-stream
435441MCP-Protocol-Version: 2026-07-28
436442Mcp-Method: tools/call
437443Mcp-Name: execute_sql
specification/2026-07-28/basic/versioning Changed · +11 / -8 lines
from line 37
3737## Protocol Version Negotiation
3838
3939Every request declares the protocol version it is using in its
40[`_meta`](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#meta) field. On HTTP, this is
40[`_meta`](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#_meta) field. On HTTP, this is
4141also carried in the
4242[`MCP-Protocol-Version` header](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http#protocol-version-header).
4343
from line 79
7979[extensions](https://modelcontextprotocol.io/docs/extensions/overview.md) beyond the core protocol. Extensions
8080are advertised in the `extensions` field of capabilities, which is a map of
8181extension identifiers to per-extension settings objects. Extension identifiers
82**MUST** follow the [`_meta` key naming rules](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#meta),
82**MUST** follow the [`_meta` key naming rules](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#_meta),
8383with a mandatory prefix.
8484
8585The following is an example of a client that advertises the
from line 87
8787
8888```json theme={null}
8989{
90 "capabilities": {
91 "roots": {},
92 "extensions": {
93 "io.modelcontextprotocol/ui": {
94 "mimeTypes": ["text/html;profile=mcp-app"]
90 "_meta": {
91 "io.modelcontextprotocol/clientCapabilities": {
92 "extensions": {
93 "io.modelcontextprotocol/ui": {
94 "mimeTypes": ["text/html;profile=mcp-app"]
95 }
9596 }
9697 }
9798 }
from line 99
9899}
99100```
100101
101An example of [Tasks extension](https://modelcontextprotocol.io/extensions/tasks/overview.md) identified as `io.modelcontextprotocol/tasks`:
102The following is an example of a server that advertises the
103[Tasks extension](https://modelcontextprotocol.io/extensions/tasks/overview.md) identified as `io.modelcontextprotocol/tasks`
104in its `server/discover` result:
102105
103106```json theme={null}
104107{
specification/2026-07-28/server/resources Changed · +6 / -6 lines
from line 13
1313> `io.modelcontextprotocol/clientInfo`, and
1414> `io.modelcontextprotocol/clientCapabilities`). Every request **MUST** include
1515> the required `_meta` fields; see
16> [`_meta`](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#meta).
16> [`_meta`](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#_meta).
1717
1818## User Interaction Model
1919
from line 51
5151
5252* `listChanged`: whether the server will emit notifications when the list of available
5353 resources changes.
54* `subscribe` : whether the server supports resource-specific update notifications
55 for resources requested through subscriptions/listen using the resourceSubscriptions
56 filter.
54* `subscribe`: whether the server supports resource-specific update notifications
55 for resources requested through `subscriptions/listen` using the
56 `resourceSubscriptions` filter.
5757
5858Servers may advertise either feature independently, together or neither.
5959
from line 172
172172
173173Servers **MAY** also respond to `resources/read` with an [`InputRequiredResult`](https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/mrtr#inputrequiredresult) to indicate that additional input is needed before the resource can be read. This follows the [multi round-trip requests](https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/mrtr.md#multi-round-trip-requests) mechanism. When retrying the request, clients include `inputResponses` and, if provided by the server, `requestState` in the request parameters.
174174
175Alternatively, if the scheme of `uri` is `https://`, clients may fetch the resource directly from the web. See the [Common URI Schemes section](#https%3A%2F%2F) for more information.
175Alternatively, if the scheme of `uri` is `https://`, clients may fetch the resource directly from the web. See the [Common URI Schemes section](#https//) for more information.
176176
177177### Resource Templates
178178
from line 394
394394### Custom URI Schemes
395395
396396Custom URI schemes **MUST** be in accordance with [RFC3986](https://datatracker.ietf.org/doc/html/rfc3986),
397taking the above guidance in to account.
397taking the above guidance into account.
398398
399399## Error Handling
400400
specification/2026-07-28/server/utilities/caching Changed · +3 / -3 lines
from line 36
3636
3737Cacheable Results in MCP use two fields to provide caching hints to clients:
3838
39* The **Time-to-live (TTL) Field**,`ttlMs`, is an integer value in milliseconds specifying how long the client MAY consider the result fresh.
40* The **Cache Scope Field**,`cacheScope`, indicates the intended scope of the cached response, either `"public"` or `"private"`.
39* The **Time-to-live (TTL) Field**, `ttlMs`, is an integer value in milliseconds specifying how long the client MAY consider the result fresh.
40* The **Cache Scope Field**, `cacheScope`, indicates the intended scope of the cached response, either `"public"` or `"private"`.
4141
4242### Time-to-Live (TTL) Field
4343
from line 166
166166
167167## Security Considerations
168168
169A `cacheScope` of `"public"` indicates that the response does not contain user-specific data and can be safely shared. Servers MUST be aware that responses with a `"public"` `cacheScope` may be shared between callers even if the Result is coming from an authenticated endpoint. For example, the Result from an authenticated `tools/list` call with a `"public"` `cacheScope` may be cached by a client and may be shared outside of the initial requests authorization context. (i.e. different access tokens can leverage the same cache).
169A `cacheScope` of `"public"` indicates that the response does not contain user-specific data and can be safely shared. Servers MUST be aware that responses with a `"public"` `cacheScope` may be shared between callers even if the Result is coming from an authenticated endpoint. For example, the Result from an authenticated `tools/list` call with a `"public"` `cacheScope` may be cached by a client and may be shared outside of the initial request's authorization context (i.e. different access tokens can leverage the same cache).
170170
171171Server implementors:
172172
specification/draft/basic/index Changed · +8 / -1 lines
from line 96
9696}
9797```
9898
99* Error responses **MUST** include the same ID as the request they correspond to (except in error cases where the ID could not be read due a malformed request).
99* Error responses **MUST** include the same ID as the request they correspond to (except in error cases where the ID could not be read due to a malformed request).
100100* Error responses **MUST** include an `error` field with a `code` and `message`.
101101* Error codes **MUST** be integers.
102102* Error responses **MAY** include a `data` member with additional information of any type, such
from line 350
350350| `io.modelcontextprotocol/clientInfo` | Client name and version | Per-request protocol fields (below) |
351351| `io.modelcontextprotocol/clientCapabilities` | Client capabilities relevant to a request | Per-request protocol fields (below) |
352352| `io.modelcontextprotocol/logLevel` | Minimum log level the server should emit for a request | [Logging](https://modelcontextprotocol.io/specification/draft/server/utilities/logging.md) |
353| `io.modelcontextprotocol/serverInfo` | Server name and version | Per-response protocol fields (below) |
353354| `io.modelcontextprotocol/subscriptionId` | Correlates a notification with its originating subscription | [Subscriptions](https://modelcontextprotocol.io/specification/draft/basic/patterns/subscriptions.md) |
354355| `traceparent`, `tracestate`, `baggage` | OpenTelemetry trace context propagation | OpenTelemetry trace context (below) |
355356
from line 437
436437 "location": "New York"
437438 },
438439 "_meta": {
440 "io.modelcontextprotocol/protocolVersion": "2026-07-28",
441 "io.modelcontextprotocol/clientInfo": {
442 "name": "ExampleClient",
443 "version": "1.0.0"
444 },
445 "io.modelcontextprotocol/clientCapabilities": {},
439446 "traceparent": "00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01"
440447 }
441448 }
specification/draft/basic/transports/streamable-http Changed · +6 / -0 lines
from line 295
295295
296296```http theme={null}
297297POST /mcp HTTP/1.1
298Host: example.com
298299Content-Type: application/json
300Accept: application/json, text/event-stream
299301MCP-Protocol-Version: 2026-07-28
300302Mcp-Method: tools/call
301303Mcp-Name: get_weather
from line 327
325327
326328```http theme={null}
327329POST /mcp HTTP/1.1
330Host: example.com
328331Content-Type: application/json
332Accept: application/json, text/event-stream
329333MCP-Protocol-Version: 2026-07-28
330334Mcp-Method: resources/read
331335Mcp-Name: file:///projects/myapp/config.json
from line 436
432436
433437```http theme={null}
434438POST /mcp HTTP/1.1
439Host: example.com
435440Content-Type: application/json
441Accept: application/json, text/event-stream
436442MCP-Protocol-Version: 2026-07-28
437443Mcp-Method: tools/call
438444Mcp-Name: execute_sql
specification/draft/basic/versioning Changed · +11 / -8 lines
from line 37
3737## Protocol Version Negotiation
3838
3939Every request declares the protocol version it is using in its
40[`_meta`](https://modelcontextprotocol.io/specification/draft/basic/index#meta) field. On HTTP, this is
40[`_meta`](https://modelcontextprotocol.io/specification/draft/basic/index#_meta) field. On HTTP, this is
4141also carried in the
4242[`MCP-Protocol-Version` header](https://modelcontextprotocol.io/specification/draft/basic/transports/streamable-http#protocol-version-header).
4343
from line 79
7979[extensions](https://modelcontextprotocol.io/docs/extensions/overview.md) beyond the core protocol. Extensions
8080are advertised in the `extensions` field of capabilities, which is a map of
8181extension identifiers to per-extension settings objects. Extension identifiers
82**MUST** follow the [`_meta` key naming rules](https://modelcontextprotocol.io/specification/draft/basic/index#meta),
82**MUST** follow the [`_meta` key naming rules](https://modelcontextprotocol.io/specification/draft/basic/index#_meta),
8383with a mandatory prefix.
8484
8585The following is an example of a client that advertises the
from line 87
8787
8888```json theme={null}
8989{
90 "capabilities": {
91 "roots": {},
92 "extensions": {
93 "io.modelcontextprotocol/ui": {
94 "mimeTypes": ["text/html;profile=mcp-app"]
90 "_meta": {
91 "io.modelcontextprotocol/clientCapabilities": {
92 "extensions": {
93 "io.modelcontextprotocol/ui": {
94 "mimeTypes": ["text/html;profile=mcp-app"]
95 }
9596 }
9697 }
9798 }
from line 99
9899}
99100```
100101
101An example of [Tasks extension](https://modelcontextprotocol.io/extensions/tasks/overview.md) identified as `io.modelcontextprotocol/tasks`:
102The following is an example of a server that advertises the
103[Tasks extension](https://modelcontextprotocol.io/extensions/tasks/overview.md) identified as `io.modelcontextprotocol/tasks`
104in its `server/discover` result:
102105
103106```json theme={null}
104107{
specification/draft/server/resources Changed · +6 / -6 lines
from line 13
1313> `io.modelcontextprotocol/clientInfo`, and
1414> `io.modelcontextprotocol/clientCapabilities`). Every request **MUST** include
1515> the required `_meta` fields; see
16> [`_meta`](https://modelcontextprotocol.io/specification/draft/basic/index#meta).
16> [`_meta`](https://modelcontextprotocol.io/specification/draft/basic/index#_meta).
1717
1818## User Interaction Model
1919
from line 51
5151
5252* `listChanged`: whether the server will emit notifications when the list of available
5353 resources changes.
54* `subscribe` : whether the server supports resource-specific update notifications
55 for resources requested through subscriptions/listen using the resourceSubscriptions
56 filter.
54* `subscribe`: whether the server supports resource-specific update notifications
55 for resources requested through `subscriptions/listen` using the
56 `resourceSubscriptions` filter.
5757
5858Servers may advertise either feature independently, together or neither.
5959
from line 172
172172
173173Servers **MAY** also respond to `resources/read` with an [`InputRequiredResult`](https://modelcontextprotocol.io/specification/draft/basic/patterns/mrtr#inputrequiredresult) to indicate that additional input is needed before the resource can be read. This follows the [multi round-trip requests](https://modelcontextprotocol.io/specification/draft/basic/patterns/mrtr.md#multi-round-trip-requests) mechanism. When retrying the request, clients include `inputResponses` and, if provided by the server, `requestState` in the request parameters.
174174
175Alternatively, if the scheme of `uri` is `https://`, clients may fetch the resource directly from the web. See the [Common URI Schemes section](#https%3A%2F%2F) for more information.
175Alternatively, if the scheme of `uri` is `https://`, clients may fetch the resource directly from the web. See the [Common URI Schemes section](#https//) for more information.
176176
177177### Resource Templates
178178
from line 394
394394### Custom URI Schemes
395395
396396Custom URI schemes **MUST** be in accordance with [RFC3986](https://datatracker.ietf.org/doc/html/rfc3986),
397taking the above guidance in to account.
397taking the above guidance into account.
398398
399399## Error Handling
400400
specification/draft/server/utilities/caching Changed · +3 / -3 lines
from line 36
3636
3737Cacheable Results in MCP use two fields to provide caching hints to clients:
3838
39* The **Time-to-live (TTL) Field**,`ttlMs`, is an integer value in milliseconds specifying how long the client MAY consider the result fresh.
40* The **Cache Scope Field**,`cacheScope`, indicates the intended scope of the cached response, either `"public"` or `"private"`.
39* The **Time-to-live (TTL) Field**, `ttlMs`, is an integer value in milliseconds specifying how long the client MAY consider the result fresh.
40* The **Cache Scope Field**, `cacheScope`, indicates the intended scope of the cached response, either `"public"` or `"private"`.
4141
4242### Time-to-Live (TTL) Field
4343
from line 166
166166
167167## Security Considerations
168168
169A `cacheScope` of `"public"` indicates that the response does not contain user-specific data and can be safely shared. Servers MUST be aware that responses with a `"public"` `cacheScope` may be shared between callers even if the Result is coming from an authenticated endpoint. For example, the Result from an authenticated `tools/list` call with a `"public"` `cacheScope` may be cached by a client and may be shared outside of the initial requests authorization context. (i.e. different access tokens can leverage the same cache).
169A `cacheScope` of `"public"` indicates that the response does not contain user-specific data and can be safely shared. Servers MUST be aware that responses with a `"public"` `cacheScope` may be shared between callers even if the Result is coming from an authenticated endpoint. For example, the Result from an authenticated `tools/list` call with a `"public"` `cacheScope` may be cached by a client and may be shared outside of the initial request's authorization context (i.e. different access tokens can leverage the same cache).
170170
171171Server implementors:
172172
docs/2026-07-28/develop/connect-remote-servers Changed · +2 / -2 lines
from line 93
9393> Create custom remote MCP servers to integrate with proprietary tools and
9494> services
9595
96> [card] [Explore available servers](https://github.com/modelcontextprotocol/servers)
96> [card] [Explore available servers](https://registry.modelcontextprotocol.io/)
9797>
98> Browse our collection of official and community-created MCP servers
98> Browse the servers published to the MCP Registry
9999
100100> [card] [Connect local servers](https://modelcontextprotocol.io/docs/2026-07-28/develop/connect-local-servers.md)
101101>
docs/2026-07-28/learn/versioning Changed · +1 / -1 lines
from line 40
4040
4141Every request declares the protocol version it is using via the
4242`io.modelcontextprotocol/protocolVersion` key in its
43[`_meta`](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#meta) field, and the server accepts or
43[`_meta`](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#_meta) field, and the server accepts or
4444rejects each request independently. On Streamable HTTP, the same value is also carried
4545in the
4646[`MCP-Protocol-Version` header](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http#protocol-version-header).
docs/2026-07-28/tools/debugging Changed · +1 / -1 lines
from line 186
186186 `UnsupportedProtocolVersionError` (`-32022`) lists the server's supported
187187 versions in its `data` field
1881885. Check the
189 [per-request `_meta` fields](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#meta):
189 [per-request `_meta` fields](https://modelcontextprotocol.io/specification/2026-07-28/basic/index#_meta):
190190 every request must carry `io.modelcontextprotocol/protocolVersion` and
191191 `io.modelcontextprotocol/clientCapabilities`, and clients should also
192192 include `io.modelcontextprotocol/clientInfo`. A request missing either
docs/2026-07-28/tools/inspector/recipes Changed · +1 / -1 lines
from line 255
255255>
256256> Each entry must include the scheme; a scheme-less value is dropped with a warning. A blank value does **not** disable the check; it falls back to the default. There is no knob to turn origin validation off.
257257
258Two further caveats when going off loopback:
258Three further caveats when going off loopback:
259259
260260* **MCP Apps need their sandbox port reachable too.** It's a separate listener (`6275` by default, set with `MCP_SANDBOX_PORT`), so expose or forward it alongside the web port.
261261* **Behind TLS or a reverse proxy, give MCP Apps their public addresses.** By default the sandbox is advertised as `http://<bind host>:6275`, which an `https://` page blocks as mixed content. Set `MCP_SANDBOX_FULL_ADDRESS` (for example `https://inspector-sandbox.example.com/sandbox`) and, for apps that declare `_meta.ui.domain`, `MCP_APP_ORIGIN_FULL_ADDRESS` (for example `https://inspector-apps.example.com`). Each needs its own hostname or port; an address that shares the Inspector's origin is refused.
docs/2026-07-28/tutorials/security/security_best_practices Changed · +1 / -1 lines
from line 643
643643* Keep sandboxing solutions up-to-date to account for emerging
644644 vulnerabilities
645645
646MCP servers intending for their servers to be run locally **SHOULD**
646MCP server developers intending for their servers to be run locally **SHOULD**
647647implement measures to prevent unauthorized usage from malicious
648648processes:
649649
docs/draft/develop/connect-remote-servers Changed · +2 / -2 lines
from line 93
9393> Create custom remote MCP servers to integrate with proprietary tools and
9494> services
9595
96> [card] [Explore available servers](https://github.com/modelcontextprotocol/servers)
96> [card] [Explore available servers](https://registry.modelcontextprotocol.io/)
9797>
98> Browse our collection of official and community-created MCP servers
98> Browse the servers published to the MCP Registry
9999
100100> [card] [Connect local servers](https://modelcontextprotocol.io/docs/draft/develop/connect-local-servers.md)
101101>
docs/draft/learn/versioning Changed · +1 / -1 lines
from line 40
4040
4141Every request declares the protocol version it is using via the
4242`io.modelcontextprotocol/protocolVersion` key in its
43[`_meta`](https://modelcontextprotocol.io/specification/draft/basic/index#meta) field, and the server accepts or
43[`_meta`](https://modelcontextprotocol.io/specification/draft/basic/index#_meta) field, and the server accepts or
4444rejects each request independently. On Streamable HTTP, the same value is also carried
4545in the
4646[`MCP-Protocol-Version` header](https://modelcontextprotocol.io/specification/draft/basic/transports/streamable-http#protocol-version-header).