example_tool_with_descriptions.py•2.51 kB
#!/usr/bin/env python
from typing import Dict, Any, Optional, List, Annotated
# Import from the MCP Python SDK
from mcp.server.fastmcp import FastMCP
# Initialize the FastMCP server
mcp = FastMCP("Parameter Description Demo")
@mcp.tool(name="search-data")
def search_data(
query: Annotated[str, "Search query string to find matching data"],
max_results: Annotated[int, "Maximum number of results to return"] = 10,
filters: Annotated[Optional[Dict[str, Any]], "Optional filters to refine search results"] = None,
sort_by: Annotated[str, "Field to sort results by"] = "relevance",
include_metadata: Annotated[bool, "Whether to include metadata in results"] = True,
) -> Dict[str, Any]:
"""
Search the database for matching data based on the provided query and filters.
This is a comprehensive search tool that allows filtering, sorting, and limiting results.
"""
# Implementation would go here
return {
"results": [],
"total_count": 0,
"query": query,
"filters_applied": filters or {},
}
@mcp.tool(name="get-project-settings")
def get_project_settings(
project_path: Annotated[Optional[str], "Optional path to the project directory"] = None,
) -> Dict[str, Any]:
"""Get the project settings for the current working directory or a proposed path."""
# Implementation would go here
return {
"success": True,
"project_path": project_path or "/default/path",
"project_type": "python",
}
@mcp.tool(name="prime-context")
def prime_context(
project_path: Annotated[Optional[str], "Path to the project. If not provided, uses project settings"] = None,
depth: Annotated[str, "Depth of analysis (minimal, standard, deep)"] = "standard"
) -> Dict[str, Any]:
"""
Prime project context by analyzing documentation and structure.
This tool analyzes the project structure and documentation to provide
context information for AI assistants working with the project.
"""
# Implementation would go here
return {
"success": True,
"message": "Context primed for project analysis",
"context": {
"project": {
"name": "demo",
"path": project_path or "/default/path",
"type": "python",
},
"depth": depth,
}
}
if __name__ == "__main__":
# Run the MCP server
print("Starting MCP server with parameter descriptions...")
mcp.run()