Skip to content

Commit e1887ee

Browse files
authored
Merge pull request #105 from Philip-Walsh/main
fix: incorrect code block end position
2 parents 45a7f6d + 2f12277 commit e1887ee

File tree

1 file changed

+55
-52
lines changed

1 file changed

+55
-52
lines changed

units/en/unit1/sdk.mdx

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -49,75 +49,78 @@ def weather_report(location: str) -> str:
4949
# Run the server
5050
if __name__ == "__main__":
5151
mcp.run()
52+
```
5253

5354
Once you have your server implemented, you can start it by running the server script.
5455

5556
```bash
5657
mcp dev server.py
5758
```
5859

59-
```
60-
6160
</hfoption>
6261
<hfoption id="javascript">
6362

6463
```javascript
6564
// index.mjs
66-
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
65+
import {
66+
McpServer,
67+
ResourceTemplate,
68+
} from "@modelcontextprotocol/sdk/server/mcp.js";
6769
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6870
import { z } from "zod";
6971

7072
// Create an MCP server
7173
const server = new McpServer({
72-
name: "Weather Service",
73-
version: "1.0.0"
74+
name: "Weather Service",
75+
version: "1.0.0",
7476
});
7577

7678
// Tool implementation
77-
server.tool("get_weather",
78-
{ location: z.string() },
79-
async ({ location }) => ({
80-
content: [{
81-
type: "text",
82-
text: `Weather in ${location}: Sunny, 72°F`
83-
}]
84-
})
85-
);
79+
server.tool("get_weather", { location: z.string() }, async ({ location }) => ({
80+
content: [
81+
{
82+
type: "text",
83+
text: `Weather in ${location}: Sunny, 72°F`,
84+
},
85+
],
86+
}));
8687

8788
// Resource implementation
8889
server.resource(
89-
"weather",
90-
new ResourceTemplate("weather://{location}", { list: undefined }),
91-
async (uri, { location }) => ({
92-
contents: [{
93-
uri: uri.href,
94-
text: `Weather data for ${location}: Sunny, 72°F`
95-
}]
96-
})
90+
"weather",
91+
new ResourceTemplate("weather://{location}", { list: undefined }),
92+
async (uri, { location }) => ({
93+
contents: [
94+
{
95+
uri: uri.href,
96+
text: `Weather data for ${location}: Sunny, 72°F`,
97+
},
98+
],
99+
})
97100
);
98101

99102
// Prompt implementation
100103
server.prompt(
101-
"weather_report",
102-
{ location: z.string() },
103-
async ({ location }) => ({
104-
messages: [
105-
{
106-
role: "assistant",
107-
content: {
108-
type: "text",
109-
text: "You are a weather reporter."
110-
}
111-
},
112-
{
113-
role: "user",
114-
content: {
115-
type: "text",
116-
text: `Weather report for ${location}?`
117-
}
118-
}
119-
]
120-
})
104+
"weather_report",
105+
{ location: z.string() },
106+
async ({ location }) => ({
107+
messages: [
108+
{
109+
role: "assistant",
110+
content: {
111+
type: "text",
112+
text: "You are a weather reporter.",
113+
},
114+
},
115+
{
116+
role: "user",
117+
content: {
118+
type: "text",
119+
text: `Weather report for ${location}?`,
120+
},
121+
},
122+
],
123+
})
121124
);
122125

123126
// Run the server
@@ -156,16 +159,16 @@ You'll see the server's capabilities and the ability to call them via the UI.
156159

157160
MCP is designed to be language-agnostic, and there are official SDKs available for several popular programming languages:
158161

159-
| Language | Repository | Maintainer(s) | Status |
160-
|----------|------------|---------------|--------|
161-
| TypeScript | [github.com/modelcontextprotocol/typescript-sdk](https://github.com/modelcontextprotocol/typescript-sdk) | Anthropic | Active |
162-
| Python | [github.com/modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) | Anthropic | Active |
163-
| Java | [github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) | Spring AI (VMware) | Active |
164-
| Kotlin | [github.com/modelcontextprotocol/kotlin-sdk](https://github.com/modelcontextprotocol/kotlin-sdk) | JetBrains | Active |
165-
| C# | [github.com/modelcontextprotocol/csharp-sdk](https://github.com/modelcontextprotocol/csharp-sdk) | Microsoft | Active (Preview) |
166-
| Swift | [github.com/modelcontextprotocol/swift-sdk](https://github.com/modelcontextprotocol/swift-sdk) | loopwork-ai | Active |
167-
| Rust | [github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) | Anthropic/Community | Active |
168-
| Dart | [https://github.com/leehack/mcp_dart](https://github.com/leehack/mcp_dart) | Flutter Community | Active |
162+
| Language | Repository | Maintainer(s) | Status |
163+
| ---------- | -------------------------------------------------------------------------------------------------------- | ------------------- | ---------------- |
164+
| TypeScript | [github.com/modelcontextprotocol/typescript-sdk](https://github.com/modelcontextprotocol/typescript-sdk) | Anthropic | Active |
165+
| Python | [github.com/modelcontextprotocol/python-sdk](https://github.com/modelcontextprotocol/python-sdk) | Anthropic | Active |
166+
| Java | [github.com/modelcontextprotocol/java-sdk](https://github.com/modelcontextprotocol/java-sdk) | Spring AI (VMware) | Active |
167+
| Kotlin | [github.com/modelcontextprotocol/kotlin-sdk](https://github.com/modelcontextprotocol/kotlin-sdk) | JetBrains | Active |
168+
| C# | [github.com/modelcontextprotocol/csharp-sdk](https://github.com/modelcontextprotocol/csharp-sdk) | Microsoft | Active (Preview) |
169+
| Swift | [github.com/modelcontextprotocol/swift-sdk](https://github.com/modelcontextprotocol/swift-sdk) | loopwork-ai | Active |
170+
| Rust | [github.com/modelcontextprotocol/rust-sdk](https://github.com/modelcontextprotocol/rust-sdk) | Anthropic/Community | Active |
171+
| Dart | [https://github.com/leehack/mcp_dart](https://github.com/leehack/mcp_dart) | Flutter Community | Active |
169172

170173
These SDKs provide language-specific abstractions that simplify working with the MCP protocol, allowing you to focus on implementing the core logic of your servers or clients rather than dealing with low-level protocol details.
171174

0 commit comments

Comments
 (0)