{"id":30420296,"url":"https://github.com/asklar/mcpextract","last_synced_at":"2025-08-22T08:18:11.066Z","repository":{"id":310142177,"uuid":"1038864410","full_name":"asklar/McpExtract","owner":"asklar","description":"Extract metadata from .net MCP tool definitions","archived":false,"fork":false,"pushed_at":"2025-08-16T01:24:08.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-16T03:37:37.142Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asklar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-16T00:59:11.000Z","updated_at":"2025-08-16T01:24:11.000Z","dependencies_parsed_at":"2025-08-16T03:37:40.121Z","dependency_job_id":"dd68a276-58c4-4ffb-8621-a19dd5abf13c","html_url":"https://github.com/asklar/McpExtract","commit_stats":null,"previous_names":["asklar/mcpextract"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/asklar/McpExtract","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asklar%2FMcpExtract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asklar%2FMcpExtract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asklar%2FMcpExtract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asklar%2FMcpExtract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asklar","download_url":"https://codeload.github.com/asklar/McpExtract/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asklar%2FMcpExtract/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271606604,"owners_count":24788981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-22T02:00:08.480Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-22T08:18:08.869Z","updated_at":"2025-08-22T08:18:11.047Z","avatar_url":"https://github.com/asklar.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# McpExtract\n\nA command line tool that extracts Model Context Protocol (MCP) tool metadata from .NET assemblies and outputs it as JSON, Python function definitions, or DXT manifests.\n\n## Why This Tool Matters\n\nThis tool bridges a critical gap between MCP server development and AI model training workflows:\n\n**The Challenge**: Organizations often have separate teams working on different parts of the AI ecosystem:\n- **MCP Server Development Teams** build sophisticated MCP servers with rich tool sets\n- **AI/ML Teams** develop and train local tool-calling models that need comprehensive training data\n\n**The Solution**: McpExtract automates the extraction of tool metadata from compiled MCP servers, enabling:\n- **Accelerated Model Retraining**: Instead of manually documenting tools for training data, extract comprehensive metadata automatically\n- **Consistent Training Data**: Ensure training data accurately reflects the actual tool signatures and descriptions\n- **Rapid Iteration**: As MCP servers evolve, quickly regenerate training data to keep models up-to-date\n- **Cross-Team Collaboration**: Enable ML teams to work with the latest tool definitions without requiring deep knowledge of the MCP server codebase\n\nThe Python output format is particularly valuable for ML workflows, providing ready-to-use function signatures that can be directly incorporated into training pipelines or used as reference implementations.\n\n## Overview\n\nThis tool scans .NET DLL files that use the [MCP SDK for C#](https://github.com/modelcontextprotocol/csharp-sdk/) and extracts information about methods annotated with `[McpServerTool(...)]` attributes. \n\nIt outputs structured JSON, Python, or DXT manifest formats, containing details about each tool including:\n\n- Tool name and description\n- Parameter information with types and descriptions\n- Return type information\n- Method and class names\n\n## Features\n\n- **AOT-Compatible**: Built with .NET 9 and native AOT support\n- **No LINQ**: Uses only loops and direct method calls for maximum compatibility\n- **System.Text.Json Source Generators**: Uses compile-time JSON serialization for performance\n- **Reflection-Based Analysis**: Analyzes target assemblies without requiring them as dependencies\n- **Multiple Output Formats**: Supports JSON, Python function definitions, and DXT manifests\n- **Command Line Interface**: Built with System.CommandLine for robust argument parsing\n- **Parameter Descriptions**: Extracts descriptions from `[Description]` attributes on methods and parameters\n\n## Workflow Integration\n\n### Typical Cross-Team Workflow\n\n1. **MCP Development Team** builds and compiles MCP servers with rich tool annotations\n2. **CI/CD Pipeline** runs McpExtract against the compiled assemblies to extract tool metadata\n3. **Training Data Pipeline** consumes the JSON/Python output to generate model training data\n4. **DXT Integration** uses the DXT manifest output to package MCP servers for distribution\n4. **ML Team** uses the extracted metadata to retrain tool-calling models with current tool definitions\n\n### Example Integration\n\n```bash\n# In your CI/CD pipeline\ndotnet build MyMcpServer.csproj\nMcpExtract bin/Release/net9.0/MyMcpServer.dll --output tools.json\nMcpExtract bin/Release/net9.0/MyMcpServer.dll --output training_functions.py --format python\nMcpExtract bin/Release/net9.0/MyMcpServer.dll --output manifest.json --format dxt\n\n# Training pipeline can now use tools.json for metadata and training_functions.py as reference\n# DXT systems can use manifest.json for MCP server distribution and integration\n```\n\n## Usage\n\n```bash\n# Basic usage - output JSON to console\nMcpExtract \u003cassembly-path\u003e\n\n# Output JSON to file\nMcpExtract \u003cassembly-path\u003e --output \u003coutput-file\u003e\n\n# Output Python function definitions\nMcpExtract \u003cassembly-path\u003e --format python\n\n# Output Python to file\nMcpExtract \u003cassembly-path\u003e --output tools.py --format python\n\n# Output DXT manifest\nMcpExtract \u003cassembly-path\u003e --format dxt\n\n# Output DXT manifest to file\nMcpExtract \u003cassembly-path\u003e --output manifest.json --format dxt\n```\n\n### Command Line Options\n\n- `\u003cassembly-path\u003e` - Path to the .NET assembly (.dll) to analyze (required)\n- `-o, --output \u003cfile\u003e` - Path for the output file. If not specified, outputs to console\n- `-f, --format \u003cjson|python|dxt\u003e` - Output format: `json` (default), `python`, or `dxt`\n- `--help` - Show help and usage information\n\n### Examples\n\n```bash\n# Analyze an MCP server assembly and output JSON to console\nMcpExtract MyMcpServer.dll\n\n# Analyze and save JSON to file\nMcpExtract MyMcpServer.dll --output tools.json\n\n# Generate Python function definitions\nMcpExtract MyMcpServer.dll --format python\n\n# Generate Python and save to file\nMcpExtract MyMcpServer.dll --output tools.py --format python\n```\n\n## Output Formats\n\n### JSON Format\n\nThe tool outputs JSON in the following structure:\n\n```json\n{\n  \"tools\": [\n    {\n      \"name\": \"echo\",\n      \"description\": \"Echo the input message\",\n      \"parameters\": [\n        {\n          \"name\": \"message\", \n          \"description\": \"The message to echo\",\n          \"type\": {\n            \"typeName\": \"string\",\n            \"isNullable\": true,\n            \"isArray\": false\n          },\n          \"isRequired\": true\n        }\n      ],\n      \"returnType\": {\n        \"typeName\": \"string\",\n        \"isNullable\": true,\n        \"isArray\": false\n      },\n      \"methodName\": \"Echo\",\n      \"className\": \"MyMcpServer.Tools.EchoTool\"\n    }\n  ]\n}\n```\n\n### Python Format\n\nWhen using `--format=python`, the tool generates Python function definitions with type hints and docstrings:\n\n```python\n# Auto-generated Python function definitions for MCP tools\n# Generated from .NET assembly analysis\n\n# Echo the input message\ndef echo(message: str) -\u003e Optional[str]:\n    \"\"\"\n    Echo the input message\n\n    Args:\n        message (str): The message to echo\n\n    Returns:\n        Optional[str]: The result of the operation\n    \"\"\"\n    # Implementation would go here\n    pass\n```\n\n### DXT Format\n\nWhen using `--format=dxt`, the tool generates a DXT manifest that follows the [DXT specification](https://github.com/anthropics/dxt/blob/main/MANIFEST.md):\n\n```json\n{\n  \"dxt_version\": \"0.1\",\n  \"name\": \"MyMcpServer\",\n  \"version\": \"1.0.0.0\",\n  \"description\": \"MCP server extracted from MyMcpServer.dll\",\n  \"author\": {\n    \"name\": \"CompanyName\",\n    \"email\": null,\n    \"url\": null\n  },\n  \"server\": {\n    \"type\": \"binary\",\n    \"entry_point\": \"MyMcpServer.dll\",\n    \"mcp_config\": {\n      \"command\": \"dotnet\",\n      \"args\": [\"${__dirname}/MyMcpServer.dll\"]\n    }\n  },\n  \"tools\": [\n    {\n      \"name\": \"echo\",\n      \"description\": \"Echo the input message\"\n    }\n  ]\n}\n```\n\nThe DXT manifest includes:\n- Assembly metadata (name, version, description, company)\n- Server configuration for running the MCP server\n- Tools array with names and descriptions extracted from MCP attributes\n- Standard DXT format for integration with DXT-compatible systems\n\n## Supported MCP Attributes\n\n- `[McpServerTool(Name = \"...\", Description = \"...\")]` - Marks a method as an MCP tool\n- `[McpToolParameter(Description = \"...\")]` - Provides parameter descriptions\n\n## Type Support\n\nThe analyzer recognizes and properly handles:\n\n- Primitive types (string, int, bool, etc.)\n- Nullable types\n- Arrays and collections (List\u003cT\u003e, IEnumerable\u003cT\u003e, etc.)\n- Task and Task\u003cT\u003e return types\n- Custom classes and structures\n\n## Building\n\n```bash\ndotnet build\n```\n\nFor AOT publication:\n\n```bash\ndotnet publish -c Release\n```\n\n## Requirements\n\n- .NET 9.0 or later\n- Target assembly must be built with .NET Framework 4.6.1+ or .NET Core/5+\n\n## Notes\n\n- The tool loads the target assembly using reflection, so it should be compatible with the current runtime\n- CancellationToken parameters are automatically excluded from the analysis\n- Task and Task\u003cT\u003e return types are unwrapped to show the actual return type\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasklar%2Fmcpextract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasklar%2Fmcpextract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasklar%2Fmcpextract/lists"}