Skip to content

[Feature]: Add prompts to Server #6

@matsjfunke

Description

@matsjfunke

Feature Summary

Add prompts to the server to provide guidance on how to use the servers tools.

Problem or Use Case

Prompts are designed to be user-controlled, meaning they are exposed from servers to clients with the intention of the user being able to explicitly select them for use.
Typically, prompts would be triggered through user-initiated commands in the user interface, which allows users to naturally discover and invoke available prompts.

Proposed Solution

create new file prompts.py

from fastmcp import FastMCP
import asyncio


# Define subserver
prompt_mcp = FastMCP()

@prompt_mcp.prompt
def find_attention_is_all_you_need() -> str:
    """Searches the Attention is all you need paper."""
    return "Search for Attention is all you need in arxiv"


# in server.py
mcp = FastMCP()

# Import subserver
async def setup():
    await mcp.import_server(prompt_mcp, prefix="prompt")

# Result: mcp now contains prefixed components:
# - prompt: "prompt_find_attention_is_all_you_need"

if __name__ == "__main__":
    asyncio.run(setup())
    mcp.run()

Alternatives Considered

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions