Foundry MCP
A comprehensive CLI tool and Model Context Protocol (MCP) server that provides deterministic tools for AI coding assistants to manage project context, specifications, and task lists. It solves the persistent problem of context management in long-term software development projects by providing centralized, structured storage outside of project directories.
๐ CLI Mode Available
As of recent updates, Foundry MCP now includes a full-featured command-line interface while maintaining complete backward compatibility as an MCP server. You can use it both ways:
- CLI Mode: Direct command-line project management and client configuration
- MCP Server Mode: Traditional MCP server for AI assistant integration (default when no command provided)
Problem Statement
Current AI coding assistant workflows suffer from several critical issues:
- Inconsistent file management: Prompt-driven systems create files in unpredictable locations
- Project directory pollution: Context management files clutter the actual codebase
- Context loss: No reliable way to pause/resume complex development tasks across sessions
- Error-prone prompting: Relying on natural language instructions for file system operations leads to inconsistent behavior
Solution Overview
Foundry MCP provides a set of MCP tools that enable deterministic project and specification management through a centralized file system outside of project directories.
Core Value Propositions
- Deterministic operations: MCP tools eliminate prompt-driven file system errors
- Clean project separation: Context files stored outside project directories
- Persistent context: Natural pause/resume functionality through structured file storage
- Hierarchical organization: Project-level context with individual specs and task lists
Features
MCP Tools
setup_project
: Create project context documents for any software projectcreate_spec
: Create new specification with task breakdownload_spec
: Load specification with full project context
MCP Prompts
execute_task
: Guide agents through task execution with proper context loading
File System Structure
~/.foundry/
โโโ project-name/
โ โโโ project/
โ โ โโโ tech-stack.md
โ โ โโโ vision.md
โ โโโ specs/
โ โโโ 20250815_feature_name/
โ โ โโโ spec.md
โ โ โโโ task-list.md
โ โ โโโ notes.md
โ โโโ 20250816_other_feature/
โ โโโ spec.md
โ โโโ task-list.md
โ โโโ notes.md
Installation
# Clone the repository
# Build the project
# The binary will be available at target/release/foundry
Quick Start
CLI Usage
# Get help for all commands
# Start MCP server (default behavior)
# or explicitly:
# Start with enhanced logging
# Install for Cursor or Claude Desktop
# Project management commands (coming in Phase 5)
MCP Server Mode
When running as an MCP server (default behavior), the system includes cursor rules that prompt appropriate tool usage:
@setup_project
โ triggerssetup_project
tool@create_spec
โ triggerscreate_spec
tool@load_spec
โ triggersload_spec
tool@execute_task
โ triggersexecute_task
prompt with smart context loading
Example Workflow
- Setup Project: Use
@setup_project [project-name] [description]
to create foundational project context - Create Specification: Use
@create_spec [description]
to create a new specification with task breakdown - Load Context: Use
@load_spec [project-name] [spec-id]
to load specification context - Execute Tasks: Use
@execute_task
to work on tasks while maintaining updated context
CLI Commands Reference
Global Options
Available with all commands:
)
Environment variable support:
# Set default log level
Server Command
Start the MCP server (default when no subcommand provided):
Options:
--port PORT
- Port for HTTP transport (default: 3000, future use)--transport MODE
- Transport mode, currently only "stdio" (default: stdio)--host HOST
- Host for HTTP mode (default: localhost, future use)--max-connections NUM
- Maximum concurrent connections (default: 10)--timeout SECONDS
- Tool execution timeout (default: 300)--backup-retention-days DAYS
- Backup file retention (default: 7)--log-format FORMAT
- Log format: pretty, json, compact (default: pretty)
Examples:
# Default MCP server
# Explicit serve with custom settings
# JSON logging for production monitoring
# Quiet mode with minimal output
Install Command
Configure AI clients to use this MCP server:
Supported Clients:
cursor
- Configure Cursor IDEclaude-desktop
- Configure Claude Desktop app
Options:
--global
- Install globally vs project-specific (future use)--dry-run
- Preview configuration changes without applying (future use)--force
- Overwrite existing configurations (future use)
Examples:
# Install for Cursor
# Install for Claude Desktop
Configuration
Configuration precedence (highest to lowest):
- CLI arguments (
--log-level debug
) - Environment variables (
LOG_LEVEL=debug
) - Configuration file (
~/.foundry/config.toml
) - Built-in defaults
Backward Compatibility
100% backward compatible - all existing MCP server integrations continue working unchanged. When run without arguments, the tool starts in MCP server mode exactly as before.
Troubleshooting
Common Issues
MCP Server Won't Start:
# Check with verbose logging
# Verify with minimal configuration
CLI Command Not Found:
# Verify installation
# Or run directly with cargo
Configuration Issues:
# Check current configuration
# Use custom config directory
# Reset environment
Logging Problems:
# Different log formats
# Adjust verbosity
Getting Help
# General help
# Command-specific help
# Version information
Development
Prerequisites
- Rust 1.70 or later
- Cargo
Building
Testing
Running
# Run as MCP server (default)
# Run specific CLI commands
# Development with custom config
Architecture
The project is organized into the following modules:
cli/
: Command-line interface with args, config, and command handlersmodels/
: Core data structures for projects, specifications, and tasksfilesystem/
: File system operations and directory managementrepository/
: Data access layer for projects and specificationshandlers/
: MCP tool implementations and server handlersutils/
: Utility functions and helpers
CLI Architecture
src/cli/args.rs
: Command-line argument definitions using clapsrc/cli/config.rs
: Configuration management with file and environment supportsrc/cli/commands/
: Command implementationsserve.rs
: MCP server mode with enhanced CLI integrationinstall.rs
: Client configuration for Cursor/Claude Desktopproject.rs
: Project management commands (Phase 5+)
src/main.rs
: CLI dispatcher with configuration precedence handling
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
[License information to be added]
Implementation Status
โ Completed Phases
- Phase 1: Core CLI Infrastructure
- Phase 2: Refactor Main Entry Point
- Phase 3: MCP Server Mode (Serve Command)
๐ง Current Development
- Phase 4: Install Command Implementation (Client configuration)
- Phase 5: Project Management Commands
- Phase 6: Specification Management Commands
๐ Progress Tracking
- See CLI_TRANSFORMATION_TASKS.md for detailed implementation progress
- See task_list.md for original project roadmap
- All existing MCP server functionality remains fully operational
๐งช Testing
Current test coverage: 118 tests passing
- Unit tests for all core modules
- Integration tests for MCP protocol
- End-to-end workflow tests
- CLI integration tests (in development)