Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,50 @@ body:
demonstrating the bug.

placeholder: |
#!/usr/bin/env uv run
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "anyio",
# "mcp",
# ]
# ///
Comment on lines +42 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this do anything? It's not obvious to me whether this needs to be included in the file or not or create a pyproject.tomlfile for this or something. Is this just a listing to explicitly list dependencies you might have to add?

If it does more than just list dependencies in plaintext it could be cool to have a comment like # list the dependencies needed to run your example here or something.
Otherwise I think this is a 10x improvement over the nonexistent example right now.

Makes it much more obvious what a good code example is!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this do anything?

uv run installs what is in those headers. uv run --help | grep script locally, and you can read about it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely convinced we need this.

At least from most of the examples I've run into they've not needed third party dependencies, and I think it's reasonable to assume the maintainers will have mcp and anyio installed as it's the requirements of the repo.

Although it's supported by uv, it's a rather obscure part of uv and may confuse users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a python thing: https://peps.python.org/pep-0723/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh huh I totally thought it was just uv.

I'm not fully against adding it if others agree, but I'm not convinced we need it.

import threading

import anyio

from mcp.client.session import ClientSession
from mcp.client.streamable_http import streamablehttp_client
from mcp.server.fastmcp import FastMCP

...

async def run_server():
mcp = FastMCP()

@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers."""
return a + b

# ...

await mcp.run_streamable_http_async()

async def run_client():
async with streamablehttp_client("http://localhost:8000/mcp") as (read_stream, write_stream, _):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()

print(f'\nTool result: {await session.call_tool("add", {"a": 1, "b": 2})}\n')

# ...


if __name__ == "__main__":
# Run the server in a background thread
threading.Thread(target=lambda: anyio.run(run_server), daemon=True).start()

anyio.run(run_client)
render: Python

- type: textarea
Expand Down
Loading