Skip to content
forked from mark3labs/mcphost

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

License

Notifications You must be signed in to change notification settings

diceone/mcphost

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCPHost πŸ€–

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

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:

  • Claude 3.5 Sonnet (claude-3-5-sonnet-20240620)
  • Any Ollama-compatible model with function calling support

Features ✨

  • Interactive conversations with either Claude 3.5 Sonnet or Ollama models
  • Support for multiple concurrent MCP servers
  • Dynamic tool discovery and integration
  • Tool calling capabilities for both model types
  • Configurable MCP server locations and arguments
  • Consistent command interface across model types
  • Configurable message history window for context management

Requirements πŸ“‹

  • Go 1.23.3 or later
  • For Claude: An Anthropic API key
  • For Ollama: Local Ollama installation with desired models
  • One or more MCP-compatible tool servers

Environment Setup πŸ”§

  1. Anthropic API Key (for Claude):
export ANTHROPIC_API_KEY='your-api-key'
  1. Ollama Setup:
ollama pull mistral
  • Ensure Ollama is running:
ollama serve

Installation πŸ“¦

Using Go Install

go install github.com/mark3labs/mcphost@latest

Using Pre-built Binaries

You can download pre-built binaries for your platform from the releases page.

  1. Download the appropriate archive for your platform:

    • Linux: mcphost_Linux_[arch].tar.gz
    • macOS: mcphost_Darwin_[arch].tar.gz
    • Windows: mcphost_Windows_[arch].zip

    Where [arch] is either x86_64 (for Intel/AMD) or arm64 (for ARM-based processors).

  2. Extract the archive:

    # For Linux/macOS
    tar xzf mcphost_[OS]_[arch].tar.gz
    
    # For Windows
    # Extract the zip file using your preferred tool
  3. Move the binary to a directory in your PATH:

    # For Linux/macOS
    sudo mv mcphost /usr/local/bin/
    
    # For Windows
    # Move mcphost.exe to a directory in your PATH

Verifying the Binary

Each release includes a checksums.txt file containing SHA256 checksums for all release artifacts. To verify your download:

  1. Download both the binary and checksums.txt
  2. Run:
    # On Linux/macOS
    sha256sum --check checksums.txt
    
    # On Windows (PowerShell)
    Get-FileHash mcphost_Windows_[arch].zip | Format-List
    # Compare the hash with the one in checksums.txt

Configuration βš™οΈ

MCPHost will automatically create a configuration file at ~/.mcp.json if it doesn't exist. You can also specify a custom location using the --config flag:

{
  "mcpServers": {
    "sqlite": {
      "command": "uvx",
      "args": [
        "mcp-server-sqlite",
        "--db-path",
        "/tmp/foo.db"
      ]
    },
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/tmp"
      ]
    }
  }
}

Each MCP server entry requires:

  • command: The command to run (e.g., uvx, npx)
  • args: Array of arguments for the command:
    • For SQLite server: mcp-server-sqlite with database path
    • For filesystem server: @modelcontextprotocol/server-filesystem with directory path

Usage πŸš€

Basic Commands

  1. Using Claude 3.5 Sonnet:
mcphost
  1. Using Ollama:
mcphost ollama --model mistral

Note: Tool support in Ollama requires models that support function calling.

Additional Options

  • Custom config file:
mcphost --config /path/to/config.json
  • Set message history window:
mcphost --message-window 15

Interactive Commands

While chatting, you can use:

  • /help: Show available commands
  • /tools: List all available tools
  • /servers: List configured MCP servers
  • /history: Display conversation history
  • /quit: Exit the application
  • Ctrl+C: Exit at any time

Global Flags

  • --config: Specify custom config file location
  • --message-window: Set number of messages to keep in context (default: 10)

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%