Labsco
mark3labs logo

MCPHost

β˜… 1,600

from mark3labs

A CLI host application that enables Large Language Models (LLMs) to interact with external tools through the Model Context Protocol (MCP).

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeQuick setup

⚠️ MCPHost is No Longer Actively Maintained

Active development on MCPHost has been stopped. This project has been succeeded by Kit, which builds on the foundations of MCPHost with a more powerful and extensible architecture.

πŸ‘‰ We recommend all users migrate to Kit.

This repository is now archived and will not receive further updates or bug fixes.


MCPHost πŸ€–

A CLI host application that enables Large Language Models (LLMs) to interact with external tools through the Model Context Protocol (MCP). Currently supports Claude, OpenAI, Google Gemini, and Ollama models.

Discuss the Project on Discord

Table of Contents

Overview 🌟

MCPHost acts as a host in the MCP client-server architecture, where:

  • Hosts (like MCPHost) are LLM applications that manage connections and interactions
  • Clients maintain 1:1 connections with MCP servers
  • Servers provide context, tools, and capabilities to the LLMs

This architecture allows language models to:

  • Access external tools and data sources πŸ› οΈ
  • Maintain consistent context across interactions πŸ”„
  • Execute commands and retrieve information safely πŸ”’

Currently supports:

  • Anthropic Claude models (Claude 3.5 Sonnet, Claude 3.5 Haiku, etc.)
  • OpenAI models (GPT-4, GPT-4 Turbo, GPT-3.5, etc.)
  • Google Gemini models (Gemini 2.0 Flash, Gemini 1.5 Pro, etc.)
  • Any Ollama-compatible model with function calling support
  • Any OpenAI-compatible API endpoint

Features ✨

  • Interactive conversations with multiple AI models
  • Non-interactive mode for scripting and automation
  • Script mode for executable YAML-based automation scripts
  • Support for multiple concurrent MCP servers
  • Tool filtering with allowedTools and excludedTools per server
  • Dynamic tool discovery and integration
  • Tool calling capabilities across all supported models
  • Configurable MCP server locations and arguments
  • Consistent command interface across model types
  • Configurable message history window for context management
  • OAuth authentication support for Anthropic (alternative to API keys)
  • Hooks system for custom integrations and security policies
  • Environment variable substitution in configs and scripts
  • Builtin servers for common functionality (filesystem, bash, todo, http)

Automation & Scripting πŸ€–

MCPHost's non-interactive mode makes it perfect for automation, scripting, and integration with other tools.

Use Cases

Shell Scripts

Copy & paste β€” that's it
#!/bin/bash
# Get weather and save to file
mcphost -p "What's the weather in New York?" --quiet > weather.txt

# Process files with AI
for file in *.txt; do
    summary=$(mcphost -p "Summarize this file: $(cat $file)" --quiet)
    echo "$file: $summary" >> summaries.txt
done

CI/CD Integration

Copy & paste β€” that's it
# Code review automation
DIFF=$(git diff HEAD~1)
mcphost -p "Review this code diff and suggest improvements: $DIFF" --quiet

# Generate release notes
COMMITS=$(git log --oneline HEAD~10..HEAD)
mcphost -p "Generate release notes from these commits: $COMMITS" --quiet

Data Processing

Copy & paste β€” that's it
# Process CSV data
mcphost -p "Analyze this CSV data and provide insights: $(cat data.csv)" --quiet

# Generate reports
mcphost -p "Create a summary report from this JSON: $(cat metrics.json)" --quiet

API Integration

Copy & paste β€” that's it
# Use as a microservice
curl -X POST http://localhost:8080/process \
  -d "$(mcphost -p 'Generate a UUID' --quiet)"

Tips for Scripting

  • Use --quiet flag to get clean output suitable for parsing (only AI response, no UI)
  • Use --compact flag for simplified output without fancy styling (when you want to see UI elements)
  • Note: --compact and --quiet are mutually exclusive - --compact has no effect with --quiet
  • Use environment variables for sensitive data like API keys instead of hardcoding them
  • Use ${env://VAR} syntax in config files and scripts for environment variable substitution
  • Combine with standard Unix tools (grep, awk, sed, etc.)
  • Set appropriate timeouts for long-running operations
  • Handle errors appropriately in your scripts
  • Use environment variables for API keys in production

Environment Variable Best Practices

Copy & paste β€” that's it
# Set sensitive variables in environment
export GITHUB_TOKEN="ghp_your_token_here"
export OPENAI_API_KEY="your_openai_key"
export DATABASE_URL="postgresql://user:pass@localhost/db"

# Use in config files
mcpServers:
  github:
    environment:
      GITHUB_TOKEN: "${env://GITHUB_TOKEN}"
      DEBUG: "${env://DEBUG:-false}"

# Use in scripts
mcphost script my-script.sh --args:username alice

MCP Server Compatibility πŸ”Œ

MCPHost can work with any MCP-compliant server. For examples and reference implementations, see the MCP Servers Repository.

Contributing 🀝

Contributions are welcome! Feel free to:

  • Submit bug reports or feature requests through issues
  • Create pull requests for improvements
  • Share your custom MCP servers
  • Improve documentation

Please ensure your contributions follow good coding practices and include appropriate tests.

License πŸ“„

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments πŸ™

  • Thanks to the Anthropic team for Claude and the MCP specification
  • Thanks to the Ollama team for their local LLM runtime
  • Thanks to all contributors who have helped improve this tool