Create Claude Model Context Protocol (MCP) tools via CLI

MCP converter converting an old project into a Claude tool

Previously, I documented my process for turning old codebases into Claude Model Context Protocol (MCP) tools.

Then I thought, "Why not make this a little bit quicker with a dedicated tool?". That's how I ended up building this CLI tool to convert existing projects into MCP servers. In this post, I'll walk through how to use it and a little bit about how it works.

Running the tool

First, you can run mcp-converter with npx:

npx mcp-converter [path to your project] --openai-api-key [your api key]
File tree selector
File tree selector

This opens up a file selector where you can select the files you want to give as context. You could give the entire project, but the more specific the files are to the logic you are trying to convert, the better the results are.

After that, the tool creates a new folder called mcp-server with your MCP tool! From there you can refer to Anthropic's quickstart guide to get the MCP server running in Claude.

Implementation

The idea for this approach came from seeing this tool called Repo Prompt, which is a Mac app that essentially constructs a giant prompt out of your project files. After using it for a while, I realized that you really can just dump a lot of text into your LLM chatbot and get reasonable results (which was definitely not the case a year ago).

For the CLI interface, the inquirer-file-tree-selection-prompt package helps you create a cli file tree selector.

From this point, the tool constructs a prompt similar to Repo Prompt. Since ChatGPT was trained after the release of MCP Protocol, it's important to include some instructions on how to create an MCP server. Without the instructions, the LLM will often return arbitrary JSON structures in the tool results instead of in the required format.

You can find the source code here.