Code2MCP: A Multi-Agent Framework for Automated Transformation of Code Repositories into Model Context Protocol Services

📅 2025-09-07
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
The “N×M” adaptation challenge—where each large language model (LLM) must be manually integrated with each tool—hinders scalable tool interoperability in the LLM ecosystem. Method: This paper proposes an LLM-driven automation framework that converts arbitrary GitHub repositories into Model Context Protocol (MCP)-compliant services in a single step. It employs a multi-agent collaborative closed-loop pipeline—comprising execution, review, and repair—integrating static code analysis, automated environment provisioning, service-oriented deployment pipelines, and LLM-assisted debugging. Contribution/Results: To our knowledge, this is the first systematic solution bridging raw open-source code to production-ready MCP services—the “last-mile” gap. The framework fully automates conversion, generating standardized MCP service interfaces and comprehensive technical documentation. The implementation is open-sourced, drastically reducing manual adaptation effort and accelerating large-scale MCP ecosystem adoption.

Technology Category

Application Category

📝 Abstract
The proliferation of Large Language Models (LLMs) has created a significant integration challenge in the AI agent ecosystem, often called the "$N imes M$ problem," where N models require custom integrations for M tools. This fragmentation stifles innovation and creates substantial development overhead. While the Model Context Protocol (MCP) has emerged as a standard to resolve this, its adoption is hindered by the manual effort required to convert the vast universe of existing software into MCP-compliant services. This is especially true for the millions of open-source repositories on GitHub, the world's largest collection of functional code. This paper introduces Code2MCP, a highly automated, agentic framework designed to transform any GitHub repository into a functional MCP service with minimal human intervention. Our system employs a multi-stage workflow that automates the entire process, from code analysis and environment configuration to service generation and deployment. A key innovation of our framework is an LLM-driven, closed-loop "Run--Review--Fix" cycle, which enables the system to autonomously debug and repair the code it generates. Code2MCP produces not only deployable services but also comprehensive technical documentation, acting as a catalyst to accelerate the MCP ecosystem by systematically unlocking the world's largest open-source code repository and automating the critical last mile of tool integration. The code is open-sourced at https://github.com/DEFENSE-SEU/MCP-Github-Agent.
Problem

Research questions and friction points this paper is trying to address.

Automates conversion of GitHub repositories into MCP services
Solves N×M integration problem between LLMs and tools
Reduces manual effort in creating Model Context Protocol services
Innovation

Methods, ideas, or system contributions that make the work stand out.

Automated transformation of GitHub repositories into MCP services
Multi-stage workflow with LLM-driven closed-loop debugging cycle
Generates deployable services and comprehensive technical documentation
🔎 Similar Papers
No similar papers found.