Speakeasy Logo
Skip to Content

Custom Prompts

You can use MCP prompts  to create reusable prompt templates and workflows for MCP. Custom prompts allow you to define structured interactions that can be invoked by MCP clients.

Building and registering custom MCP prompts

Below are examples of custom MCP prompts that demonstrate different patterns for prompt creation:

Prompt patterns

Simple prompts

For basic prompts without parameters:

Parameterized prompts

For prompts that accept arguments:

Multi-step prompts

For complex workflows with multiple interactions:

Setting up MCP extensions

To register your custom prompts, add them to your server.extensions.ts file:

After adding the server.extensions.ts file and defining your custom prompts, execute speakeasy run to regenerate your MCP server with the new prompts.

Best practices

  • Use clear, descriptive names for your prompts that indicate their purpose
  • Provide detailed descriptions to help users understand when to use each prompt
  • Validate input parameters using Zod schemas for type safety
  • Structure messages logically with appropriate roles (system, user, assistant)
  • Handle edge cases gracefully with fallback content
  • Test prompts thoroughly with various input combinations
  • Keep prompts focused on specific tasks rather than trying to handle everything
  • Use consistent formatting for similar types of prompts across your server

Last updated on