Add Python stubs
This commit is contained in:
parent
61f6e3483d
commit
a2e6868c40
1 changed files with 65 additions and 47 deletions
|
|
@ -36,6 +36,8 @@ flowchart LR
|
||||||
|
|
||||||
The protocol layer handles message framing, request/response linking, and high-level communication patterns.
|
The protocol layer handles message framing, request/response linking, and high-level communication patterns.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<Tab title="TypeScript">
|
||||||
```typescript
|
```typescript
|
||||||
class Protocol<Request, Notification, Result> {
|
class Protocol<Request, Notification, Result> {
|
||||||
// Handle incoming requests
|
// Handle incoming requests
|
||||||
|
|
@ -51,6 +53,13 @@ class Protocol<Request, Notification, Result> {
|
||||||
notification(notification: Notification): Promise<void>
|
notification(notification: Notification): Promise<void>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</Tab>
|
||||||
|
<Tab title="Python">
|
||||||
|
```python
|
||||||
|
# Python implementation coming soon
|
||||||
|
```
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
Key classes include:
|
Key classes include:
|
||||||
|
|
||||||
|
|
@ -169,6 +178,8 @@ Errors are propagated through:
|
||||||
|
|
||||||
Here's a basic example of implementing an MCP server:
|
Here's a basic example of implementing an MCP server:
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<Tab title="TypeScript">
|
||||||
```typescript
|
```typescript
|
||||||
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
||||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||||
|
|
@ -198,6 +209,13 @@ server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
||||||
const transport = new StdioServerTransport();
|
const transport = new StdioServerTransport();
|
||||||
await server.connect(transport);
|
await server.connect(transport);
|
||||||
```
|
```
|
||||||
|
</Tab>
|
||||||
|
<Tab title="Python">
|
||||||
|
```python
|
||||||
|
# Python implementation coming soon
|
||||||
|
```
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
|
|
||||||
## Best practices
|
## Best practices
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue