Table of Contents
Fetching ...

Code2MCP: Transforming Code Repositories into MCP Services

Chaoqian Ouyang, Ling Yue, Shimin Di, Libin Zheng, Linan Yue, Shaowu Pan, Jian Yin, Min-Ling Zhang

TL;DR

This paper tackles the MCP supply-side bottleneck by introducing Code2MCP, an automated, multi-agent framework that converts arbitrary GitHub repositories into MCP-compatible services via a Run-Review-Fix self-correction loop. It demonstrates scalability across diverse scientific domains and shows improved end-to-end performance and reliability compared to human wrappers and GPT-4 templates. The work also validates integration with existing tool ecosystems (RepoMaster/OpenAgents) and presents concrete case studies (protein, symbolic mathematics, and CFD) to illustrate practical MCP tool generation. The findings suggest a scalable pathway to populate the MCP tool pool, accelerating adoption and real-world utility, while outlining concrete directions for security hardening and standardized benchmarks.

Abstract

The Model Context Protocol (MCP) aims to create a standard for how Large Language Models use tools. However, most current research focuses on selecting tools from an existing pool. A more fundamental, yet largely overlooked, problem is how to populate this pool by converting the vast number of existing software projects into MCP-compatible services. To bridge this gap, we introduce Code2MCP, an agent-based framework that automatically transforms a GitHub repository into a functional MCP service with minimal human intervention. Code2MCP employs a multi-agent workflow for code analysis, environment setup, tool function design, and service generation, enhanced by a self-correcting loop to ensure reliability. We demonstrate that Code2MCP successfully transforms open-source computing libraries in scientific fields such as bioinformatics, mathematics, and fluid dynamics that are not available in existing MCP servers. By providing a novel automated pathway to unlock GitHub, the world's largest code repository, for the MCP ecosystem, Code2MCP serves as a catalyst to significantly accelerate the protocol's adoption and practical application. The code is public at https://github.com/DEFENSE-SEU/Code2MCP.

Code2MCP: Transforming Code Repositories into MCP Services

TL;DR

This paper tackles the MCP supply-side bottleneck by introducing Code2MCP, an automated, multi-agent framework that converts arbitrary GitHub repositories into MCP-compatible services via a Run-Review-Fix self-correction loop. It demonstrates scalability across diverse scientific domains and shows improved end-to-end performance and reliability compared to human wrappers and GPT-4 templates. The work also validates integration with existing tool ecosystems (RepoMaster/OpenAgents) and presents concrete case studies (protein, symbolic mathematics, and CFD) to illustrate practical MCP tool generation. The findings suggest a scalable pathway to populate the MCP tool pool, accelerating adoption and real-world utility, while outlining concrete directions for security hardening and standardized benchmarks.

Abstract

The Model Context Protocol (MCP) aims to create a standard for how Large Language Models use tools. However, most current research focuses on selecting tools from an existing pool. A more fundamental, yet largely overlooked, problem is how to populate this pool by converting the vast number of existing software projects into MCP-compatible services. To bridge this gap, we introduce Code2MCP, an agent-based framework that automatically transforms a GitHub repository into a functional MCP service with minimal human intervention. Code2MCP employs a multi-agent workflow for code analysis, environment setup, tool function design, and service generation, enhanced by a self-correcting loop to ensure reliability. We demonstrate that Code2MCP successfully transforms open-source computing libraries in scientific fields such as bioinformatics, mathematics, and fluid dynamics that are not available in existing MCP servers. By providing a novel automated pathway to unlock GitHub, the world's largest code repository, for the MCP ecosystem, Code2MCP serves as a catalyst to significantly accelerate the protocol's adoption and practical application. The code is public at https://github.com/DEFENSE-SEU/Code2MCP.

Paper Structure

This paper contains 24 sections, 12 figures, 5 tables, 1 algorithm.

Figures (12)

  • Figure 1: While most research focuses on the consumption of tools (right side), one bottleneck is their supply (left side). Code2MCP solves the supply problem by converting the code repository into a standardized MCP-compliant tool.
  • Figure 2: Overview of the Code2MCP framework. The system takes a GitHub repository URL as input and automatically generates a complete MCP service through a multi-agent workflow.
  • Figure 3: Distribution of 42 failure labels assigned to the 18 failed repositories. A single repository can trigger multiple failure types across different Run-Review-Fix rounds.
  • Figure 4: Repo success rates with and without Run‑Review‑Fix (left) and remaining errors across RRF rounds (right) for five representative scientific MCP repositories.
  • Figure 5: Average task success rate (left) and average completion time (right) across the ten scientific domains for the three configurations: Human experts, GPT-4 with basic scaffolding, and Code2MCP.
  • ...and 7 more figures