Skip to content

Commit

Permalink
Merge pull request #66 from simonw/patch-1
Browse files Browse the repository at this point in the history
Fix first Python demo so it works without further modifications
  • Loading branch information
dsp-ant authored Nov 25, 2024
2 parents 6063b09 + 569acf0 commit e414828
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ Connections between clients and servers are established through transports like
MCP servers follow a decorator approach to register handlers for MCP primitives like resources, prompts, and tools. The goal is to provide a simple interface for exposing capabilities to LLM clients.

```python
# /// script
# dependencies = [
# "mcp"
# ]
# ///
from mcp.server import Server, NotificationOptions
from mcp.server.models import InitializationOptions
import mcp.server.stdio
Expand Down Expand Up @@ -122,20 +127,25 @@ async def handle_get_prompt(
]
)

# Run the server as STDIO
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
InitializationOptions(
server_name="example",
server_version="0.1.0",
capabilities=server.get_capabilities(
notification_options=NotificationOptions(),
experimental_capabilities={},
async def run():
# Run the server as STDIO
async with mcp.server.stdio.stdio_server() as (read_stream, write_stream):
await server.run(
read_stream,
write_stream,
InitializationOptions(
server_name="example",
server_version="0.1.0",
capabilities=server.get_capabilities(
notification_options=NotificationOptions(),
experimental_capabilities={},
)
)
)
)

if __name__ == "__main__":
import asyncio
asyncio.run(run())
```

### Creating a Client
Expand Down

0 comments on commit e414828

Please sign in to comment.