Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:16:51 +08:00
commit 4e8a12140c
88 changed files with 17078 additions and 0 deletions

View File

@@ -0,0 +1,144 @@
# Common MCP Server Patterns
database_integration:
name: "Database Integration"
description: "Connect AI to databases (PostgreSQL, MySQL, MongoDB)"
typical_tools:
- query_database: "Execute SQL queries with safety checks"
- get_schema: "Retrieve database schema information"
- list_tables: "List all available tables"
- describe_table: "Get detailed table structure"
typical_resources:
- "db://tables/{table}/schema"
- "db://tables/{table}/sample-data"
dependencies:
typescript: ["pg", "mysql2", "mongodb"]
python: ["psycopg2", "pymysql", "pymongo"]
security_notes:
- "Use read-only connections when possible"
- "Implement query validation to prevent SQL injection"
- "Never expose raw connection strings"
api_wrapper:
name: "API Wrapper"
description: "Wrap REST APIs for AI consumption"
typical_tools:
- search_api: "Search endpoint with filters"
- get_resource: "Fetch specific resource by ID"
- list_resources: "List resources with pagination"
- create_resource: "Create new resource (with approval)"
typical_resources:
- "api://endpoints/{endpoint}"
- "api://docs/{path}"
dependencies:
typescript: ["axios", "node-fetch"]
python: ["httpx", "requests"]
security_notes:
- "Store API keys in environment variables"
- "Implement rate limiting"
- "Validate all responses"
filesystem_access:
name: "File System Access"
description: "Secure file operations with access controls"
typical_tools:
- search_files: "Search files by pattern or content"
- read_file: "Read file contents (with permission check)"
- list_directory: "List directory contents"
- get_file_info: "Get file metadata"
typical_resources:
- "file:///{absolute_path}"
- "file:///workspace/{relative_path}"
dependencies:
typescript: ["fs/promises", "glob", "ignore"]
python: ["pathlib", "glob", "gitignore_parser"]
security_notes:
- "Implement strict path validation (prevent ../ attacks)"
- "Use allowlist/denylist for directories"
- "Never allow writes without explicit approval"
workflow_automation:
name: "Workflow Automation"
description: "Trigger and monitor automated workflows"
typical_tools:
- trigger_workflow: "Start a workflow with parameters"
- get_workflow_status: "Check workflow execution status"
- list_workflows: "List available workflows"
- cancel_workflow: "Cancel running workflow"
typical_prompts:
- deployment_workflow: "Template for deployment approvals"
- testing_workflow: "Template for test execution"
dependencies:
typescript: ["@actions/core", "@octokit/rest"]
python: ["github", "gitlab"]
security_notes:
- "Require approval for destructive operations"
- "Log all workflow executions"
- "Implement timeout mechanisms"
search_integration:
name: "Search Integration"
description: "Connect to search engines and indexing systems"
typical_tools:
- search: "Full-text search with filters"
- semantic_search: "Vector-based semantic search"
- index_document: "Add document to search index"
typical_resources:
- "search://query/{query}"
- "search://document/{doc_id}"
dependencies:
typescript: ["@elastic/elasticsearch", "typesense"]
python: ["elasticsearch", "typesense"]
security_notes:
- "Sanitize search queries"
- "Implement access control on results"
- "Rate limit search requests"
notification_system:
name: "Notification System"
description: "Send notifications via email, Slack, SMS"
typical_tools:
- send_notification: "Send notification to channel"
- get_notification_history: "Retrieve past notifications"
- create_alert: "Set up automated alerts"
dependencies:
typescript: ["@slack/web-api", "nodemailer", "twilio"]
python: ["slack_sdk", "sendgrid", "twilio"]
security_notes:
- "Validate recipient addresses"
- "Prevent notification spam"
- "Never expose credentials in logs"
data_processing:
name: "Data Processing Pipeline"
description: "Transform, analyze, and aggregate data"
typical_tools:
- transform_data: "Apply transformations to dataset"
- aggregate_data: "Compute aggregations and statistics"
- validate_data: "Validate data against schema"
typical_resources:
- "data://dataset/{name}"
- "data://schema/{schema_id}"
dependencies:
typescript: ["papaparse", "lodash", "ajv"]
python: ["pandas", "numpy", "jsonschema"]
security_notes:
- "Validate data schemas"
- "Implement size limits"
- "Sanitize outputs"
authentication_service:
name: "Authentication Service"
description: "User authentication and authorization checks"
typical_tools:
- verify_token: "Validate authentication token"
- get_user_permissions: "Retrieve user permissions"
- check_access: "Check if user has access to resource"
dependencies:
typescript: ["jsonwebtoken", "passport", "bcrypt"]
python: ["pyjwt", "passlib", "python-jose"]
security_notes:
- "Never expose secrets or tokens"
- "Use secure token storage"
- "Implement token expiration"
- "Log all authentication attempts"

View File

@@ -0,0 +1,168 @@
# Example Tool Definitions for Common Use Cases
database_query:
name: "query_database"
description: "Execute a SQL query against the database (read-only)"
params:
- name: "query"
type: "string"
description: "SQL query to execute (SELECT only)"
- name: "limit"
type: "number"
description: "Maximum number of rows to return (default: 100)"
optional: true
returns: "Array of result rows as JSON objects"
implementation_notes:
- "Validate query is SELECT only (no INSERT/UPDATE/DELETE)"
- "Apply row limits to prevent large responses"
- "Handle connection errors gracefully"
- "Format results as JSON for easy AI parsing"
web_search:
name: "search_web"
description: "Search the web using a search engine API"
params:
- name: "query"
type: "string"
description: "Search query string"
- name: "num_results"
type: "number"
description: "Number of results to return (default: 10)"
optional: true
returns: "Array of search results with title, URL, and snippet"
implementation_notes:
- "Use search API (Google Custom Search, Bing, etc.)"
- "Cache results to avoid rate limits"
- "Return structured data (title, url, description)"
- "Handle API errors and quota limits"
file_search:
name: "search_files"
description: "Search for files matching a pattern or containing text"
params:
- name: "pattern"
type: "string"
description: "File pattern (glob) or search term"
- name: "directory"
type: "string"
description: "Directory to search in (default: current)"
optional: true
- name: "search_content"
type: "boolean"
description: "Search file contents, not just names (default: false)"
optional: true
returns: "Array of file paths matching the pattern or containing the text"
implementation_notes:
- "Validate directory path (prevent path traversal)"
- "Respect .gitignore patterns"
- "Limit search depth and file count"
- "Use efficient search algorithms (ripgrep, etc.)"
send_email:
name: "send_email"
description: "Send an email message"
params:
- name: "to"
type: "string"
description: "Recipient email address"
- name: "subject"
type: "string"
description: "Email subject line"
- name: "body"
type: "string"
description: "Email body (plain text or HTML)"
- name: "html"
type: "boolean"
description: "Whether body is HTML (default: false)"
optional: true
returns: "Confirmation message with message ID"
implementation_notes:
- "Validate email addresses"
- "Use transactional email service (SendGrid, SES, etc.)"
- "Implement rate limiting"
- "Log all sent emails"
- "Require user approval for sensitive sends"
create_ticket:
name: "create_ticket"
description: "Create a new issue or ticket in project management system"
params:
- name: "title"
type: "string"
description: "Issue title"
- name: "description"
type: "string"
description: "Detailed issue description"
- name: "priority"
type: "string"
description: "Priority level (low, medium, high, critical)"
optional: true
- name: "assignee"
type: "string"
description: "Username to assign ticket to"
optional: true
returns: "Created ticket ID and URL"
implementation_notes:
- "Integrate with Jira, GitHub Issues, Linear, etc."
- "Validate priority values"
- "Apply default labels/tags"
- "Return link to created ticket"
calculate_metrics:
name: "calculate_metrics"
description: "Calculate metrics from a dataset"
params:
- name: "dataset"
type: "array"
description: "Array of data points"
- name: "metrics"
type: "array"
description: "List of metrics to calculate (mean, median, sum, etc.)"
returns: "Object with calculated metric values"
implementation_notes:
- "Support common statistical operations"
- "Handle missing or invalid data"
- "Return results in structured format"
- "Optimize for large datasets"
format_code:
name: "format_code"
description: "Format source code using language-specific formatter"
params:
- name: "code"
type: "string"
description: "Source code to format"
- name: "language"
type: "string"
description: "Programming language (javascript, python, etc.)"
- name: "style"
type: "string"
description: "Style guide (standard, prettier, black, etc.)"
optional: true
returns: "Formatted code string"
implementation_notes:
- "Use language-specific formatters (prettier, black, etc.)"
- "Handle syntax errors gracefully"
- "Support multiple style configurations"
- "Preserve comments and structure"
translate_text:
name: "translate_text"
description: "Translate text between languages"
params:
- name: "text"
type: "string"
description: "Text to translate"
- name: "source_lang"
type: "string"
description: "Source language code (auto-detect if omitted)"
optional: true
- name: "target_lang"
type: "string"
description: "Target language code"
returns: "Translated text string"
implementation_notes:
- "Use translation API (Google Translate, DeepL, etc.)"
- "Support language auto-detection"
- "Handle API rate limits"
- "Cache common translations"