python-sdk/examples/servers/simple-tool
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Yukuan Jia 340af403bd
Replace deprecated dev-dependencies with dependency-groups (#1488)
Co-authored-by: Felix Weinberger <fweinberger@anthropic.com>
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
2025-10-23 17:22:16 -07:00
..
mcp_simple_tool Add pyright strict mode on the whole project (#1254) 2025-08-11 18:56:37 +01:00
.python-version pin to lowest supported python version 2024-11-13 10:44:54 +00:00
pyproject.toml Replace deprecated dev-dependencies with dependency-groups (#1488) 2025-10-23 17:22:16 -07:00
README.md Fix READMEs of examples 2024-12-03 22:35:52 +00:00

A simple MCP server that exposes a website fetching tool.

Usage

Start the server using either stdio (default) or SSE transport:

# Using stdio transport (default)
uv run mcp-simple-tool

# Using SSE transport on custom port
uv run mcp-simple-tool --transport sse --port 8000

The server exposes a tool named "fetch" that accepts one required argument:

  • url: The URL of the website to fetch

Example

Using the MCP client, you can use the tool like this using the STDIO transport:

import asyncio
from mcp.client.session import ClientSession
from mcp.client.stdio import StdioServerParameters, stdio_client


async def main():
    async with stdio_client(
        StdioServerParameters(command="uv", args=["run", "mcp-simple-tool"])
    ) as (read, write):
        async with ClientSession(read, write) as session:
            await session.initialize()

            # List available tools
            tools = await session.list_tools()
            print(tools)

            # Call the fetch tool
            result = await session.call_tool("fetch", {"url": "https://example.com"})
            print(result)


asyncio.run(main())