Building Your Own MCP Server for AI

Prompts

Add reusable MCP prompts and know when they help versus stuffing the host system message.

An MCP prompt is a named template the host can offer: “review this function,” “turn these logs into a timeline.” It is not a replacement for the product’s system prompt, and it is not a tool.

When a prompt is useful

  • The wording is stable and you are tired of pasting it into chat.
  • The template needs an argument (a language, a severity, a file name) but no side effect.
  • Several people share the same server and should start from the same recipe.

When to skip it

If the user already typed a clear request, a prompt adds a click. If the work needs live data or a write, that is a tool. If the text is secret policy, keep it on the host — a prompt is visible to whoever can list prompts.

Register a prompt

from mcp.server.mcpserver import MCPServer

mcp = MCPServer("reviews")


@mcp.prompt()
def review_python(code: str) -> str:
    '''Ask for a tight code review of a Python snippet.'''
    return (
        "Review this Python for bugs, missing validation, and unclear names. "
        "Do not rewrite the whole file. List findings as bullets.\n\n"
        f"```python\n{code}\n```"
    )

The host lists review_python. The user (or the product UI) fills code. The model then sees the expanded string. Your server did not run the review — it only supplied the instructions.

Check it

In the inspector, open Prompts, run review_python with a five-line snippet, and confirm the returned message includes the fence. Next: connect the same server to a real AI client.