About MCP Host CLI
MCP Host CLI is a FastAPI chat server that sends requests to OpenAI-compatible LLM APIs and supports configurable MCP server settings. It provides session, chat, and tool-approval endpoints for local use.
Key features
- 01FastAPI chat endpoints
- 02Configurable LLM provider and model
- 03Environment and CLI configuration
- 04Tool approval and session endpoints
- 05Optional streaming and error retries
Use cases
- 01Hosting a local LLM chat API
- 02Managing chat sessions over HTTP
- 03Reviewing tool calls before approval
MCP support
The server accepts an MCP servers configuration file through `--servers-config` and can handle tool approvals. The README does not specify its MCP server connection protocol.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMELLM Chat Server
FastAPI server for chat interactions with LLMs (OpenAI).
Configuration
Configuration is managed via environment variables and CLI arguments.
Environment Variables
| Variable | Description | Default |
|---|---|---|
LLM_API_KEY | API key for LLM provider (alternative to --api-key-file) | - |
LLM_MODEL | Model name to use | qwen2.5-coder:latest |
PORT | Port to run server on | 8000 |
LLM_PROVIDER | LLM provider (openai) | openai |
OPENAI_BASE_URL | Base URL for OpenAI-compatible API | https://openrouter.ai/api/v1 |
Example .env file:
LLM_API_KEY=your-api-key
LLM_MODEL=qwen2.5-coder:latest
PORT=8000
LLM_PROVIDER=openai
CLI Arguments
| Argument | Description | Example |
|---|---|---|
--model | LLM model to use | --model qwen2.5-coder:latest |
--port | Port to run server on | --port 8000 |
--provider | LLM provider (openai) | --provider openai |
--openai-base-url | Base URL for OpenAI API | --openai-base-url https://api.openai.com/v1 |
--api-key-file | Path to file containing the API key | --api-key-file /path/to/api.key |
--servers-config | Path to servers config file | --servers-config config/servers.json |
--current-directory | Working directory | --current-directory /projects |
--context-window-size | Context window size | --context-window-size 2048 |
--temperature | Temperature parameter | --temperature 0.7 |
--stream | Enable streaming mode | --stream |
--retries-on-llm-error | Number of retries on LLM error | --retries-on-llm-error 3 |
--debug-messages | Enable debug messages logging to /tmp/llm-requester.messages.log | --debug-messages |
Example CLI usage:
# Using environment variable
export LLM_API_KEY=your-api-key
uv run main.py --model qwen2.5-coder:latest --port 8000
# Using API key file
uv run main.py --model qwen2.5-coder:latest --port 8000 --api-key-file /path/to/api.key
API Endpoints
POST /user_request- Handle user chat requestsPOST /approve- Handle tool approval/denialGET /session_state- Get current session statePOST /start_session- Create new session
Request/Response Format
Request (POST /user_request)
{
"input": "user message"
}
Response
{
"request_id": "uuid",
"requires_approval": true,
"tool": {
"name": "tool-name",
"arguments": {
"arg1": "value1",
"arg2": "value2"
}
},
"message": "response content",
"model": "model-name",
"role": "assistant"
}
Tool Approval (POST /approve)
{
"request_id": "uuid",
"approve": true
}
Example Usage
import requests
# Start session
response = requests.post("http://localhost:8000/start_session", json={
"current_directory": "/projects",
"model": "qwen2.5-coder:latest"
})
# Send message
response = requests.post("http://localhost:8000/user_request", json={
"input": "Hello, how are you?"
})
# Approve tool call
response = requests.post("http://localhost:8000/approve", json={
"request_id": "12345",
"approve": true
})
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.