python-sdk/examples/servers/simple-prompt
Repository files (latest commit first)
Filename Latest commit message Latest commit date
David Soria Parra bbd9d05851
Fix example servers SSE invocation
Reported-by: Simon Willison
2024-11-22 10:45:24 +00:00
..
mcp_simple_prompt Fix example servers SSE invocation 2024-11-22 10:45:24 +00:00
.python-version pin to lowest supported python version 2024-11-13 10:44:54 +00:00
pyproject.toml Example server to expose a fetch tool and a fetch prompt 2024-11-12 13:53:36 +00:00
README.md Example server to expose a fetch tool and a fetch prompt 2024-11-12 13:53:36 +00:00
uv.lock Example server to expose a fetch tool and a fetch prompt 2024-11-12 13:53:36 +00:00

MCP Simple Prompt

A simple MCP server that exposes a customizable prompt template with optional context and topic parameters.

Usage

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

# Using stdio transport (default)
mcp-simple-prompt

# Using SSE transport on custom port
mcp-simple-prompt --transport sse --port 8000

The server exposes a prompt named "simple" that accepts two optional arguments:

  • context: Additional context to consider
  • topic: Specific topic to focus on

Example

Using the MCP client, you can retrieve the prompt like this:

from mcp.client import ClientSession

async with ClientSession() as session:
    await session.initialize()

    # List available prompts
    prompts = await session.list_prompts()
    print(prompts)

    # Get the prompt with arguments
    prompt = await session.get_prompt("simple", {
        "context": "User is a software developer",
        "topic": "Python async programming"
    })
    print(prompt)