</>MCP Agents Market
MCP Server

code2prompt

by mufeedvh7.6kRustUpdated 2026-06-29

A CLI tool to convert your codebase into a single LLM prompt with source tree, prompt templating, and token counting.

The code2prompt MCP server transforms entire codebases into structured prompts optimized for large language models. It provides a local service that AI agents can query to retrieve formatted code context without manually copying files or bloating context windows. Built in Rust for performance, it respects .gitignore rules, supports custom templates, tracks token usage, and integrates Git metadata like diffs and logs. Developers can use it through multiple interfaces: a CLI tool, an interactive TUI, a Python SDK, or as an MCP server for agentic workflows.

Key Features

Interactive Terminal User Interface (TUI) for configuring and generating prompts
Smart file filtering with glob patterns and automatic .gitignore respect
Handlebars template system for customizable prompt formatting
Token counting to monitor and stay within LLM context limits
Git integration including diffs, logs, and branch comparisons
Multi-format file reading (CSV, Jupyter notebooks, JSONL) optimized for LLMs
Rust core library with Python bindings for scripting and automation
MCP server mode enabling AI agents to query codebases as a local service

Use Cases

  • 01Preparing entire project context for code review with ChatGPT or Claude
  • 02Building AI agents that need to read and understand local codebases via Python SDK
  • 03Generating code documentation prompts with custom templates for specific LLMs
  • 04Creating context for debugging sessions that include Git history and diffs
  • 05Automating RAG pipeline ingestion of source code repositories
  • 06Running a persistent MCP server for agentic applications to query code without context bloat

Related MCP Servers

View more

code2prompt — FAQ

What is the code2prompt MCP server?+

Code2prompt is a context engineering tool that converts codebases into structured prompts for large language models. It runs as an MCP server to provide AI agents efficient access to local code repositories, or as a CLI/TUI for manual prompt generation.

How do I install code2prompt?+

Install via Cargo with 'cargo install code2prompt', Homebrew with 'brew install code2prompt', or pip for Python bindings with 'pip install code2prompt-rs'. For Wayland clipboard support, use 'cargo install --features wayland code2prompt'.

Which AI clients work with code2prompt?+

The MCP server mode is designed for agentic applications that support the Model Context Protocol. The CLI and Python SDK outputs can be used with any LLM including ChatGPT, Claude, and other models that accept text prompts.

Do I need API keys to use code2prompt?+

No API keys are required. Code2prompt is a local tool that processes your codebase and generates formatted output without external API calls.

Is code2prompt free to use?+

Yes, code2prompt is open source and licensed under the MIT License, making it free for both personal and commercial use.

What are the system requirements?+

Code2prompt requires Rust and Cargo for source builds, or you can download pre-built binaries. The Python SDK requires Python 3.x. Git integration features require Git to be installed on your system.

How do I install code2prompt?+

Open the source repository on GitHub and follow its README. code2prompt is a mcp server — MCP Agents Market links you directly to the official repo.

Is code2prompt free?+

code2prompt is an open-source project hosted on GitHub. Check the repository for its license and any usage requirements.

Related searches