Skip to content

🚀 Add @mcp.prompt to MCP Server #153

@ChengJiale150

Description

@ChengJiale150

Summary

Hi everyone 👋

This proposal aims to implement the Prompt Section from the MCP specification, transforming our daily use prompt into a modular, reusable, and parameter-driven system.

This improvement will allow us to create standardized, high-quality instructions for common tasks and will greatly simplify the process for the community to contribute and share new prompts.

Proposed Implementation

Here is a simple example of how we could define a prompt for data cleaning:

from typing import Literal
from mcp.server.fastmcp.prompts.base import UserMessage 

@mcp.prompt
async def data_clean(target: Literal["missing", "outlier"]):
    """
    Generates instructions for detecting and handling missing values or outliers.
    """
    if target == "missing":
        return [UserMessage(content="""
        Next, you need to detect and handle missing values in the dataset. 
        Please analyze the extent of missing data and choose an appropriate strategy (e.g., imputation or removal).
        """)]
    elif target == "outlier":
        return [UserMessage(content="""
        Next, you need to detect and handle outliers in the dataset.
        Please use statistical methods (like Z-score or IQR) to identify outliers and decide on a handling approach.
        """)]

As shown above, the data_clean prompt can accept a target parameter and dynamically generate different, more targeted instructions based on its value ("missing" or "outlier").

This approach greatly enhances the flexibility and reusability of prompts and you can easily trigger it in your MCP Client which support MCP Prompt Feature by using /data_clean target=missing.

Call for Feedback: Help Us Build the Prompts You Need

To ensure this feature truly meets your daily workflow needs, we need your valuable input.

The core question is: In your daily workflow, what reusable and parameter-driven prompts would be most helpful to you?

We are looking for your ideas on the following categories (but not limited to):

  • Exploratory Data Analysis (EDA)
  • Data Visualization
  • Feature Engineering
  • Model Training & Evaluation
  • Code Refactoring & Documentation

Please share your thoughts. No idea is too small. They will all help us build a smarter and more efficient AI assistant.

Context & References

We look forward to your participation and discussion!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions