llama-mcp-server
MCP server bridging Claude Code to local llama.cpp. Run local LLMs alongside Claude for experimentation, testing, and cost-effective inference.
README
llama-mcp-server
MCP server bridging Claude Code to local llama.cpp. Run local LLMs alongside Claude for experimentation, testing, and cost-effective inference.
Requirements
- Node.js 18+
- llama.cpp with
llama-serverbuilt - A GGUF model file
Installation
npm install llama-mcp-server
Or clone and build from source:
git clone https://github.com/ahays248/llama-mcp-server
cd llama-mcp-server
npm install
npm run build
Configuration
Configure via environment variables:
| Variable | Description | Default |
|---|---|---|
LLAMA_SERVER_URL |
URL of llama-server | http://localhost:8080 |
LLAMA_SERVER_TIMEOUT |
Request timeout in ms | 30000 |
LLAMA_MODEL_PATH |
Path to GGUF model file | (none) |
LLAMA_SERVER_PATH |
Path to llama-server binary | llama-server |
Usage with Claude Code
Option 1: Plugin Installation (Recommended)
Due to a known bug in Claude Code, non-plugin MCP servers may connect but not expose their tools. The workaround is to install llama-mcp-server as a plugin via a local marketplace.
Step 1: Create the marketplace structure
llama-marketplace/
├── .claude-plugin/
│ └── marketplace.json
└── plugins/
└── llama/
├── .claude-plugin/
│ └── plugin.json
└── .mcp.json
Step 2: Create marketplace.json
// llama-marketplace/.claude-plugin/marketplace.json
{
"name": "llama-marketplace",
"description": "Local marketplace for llama.cpp MCP plugin",
"owner": {
"name": "Your Name"
},
"plugins": [
{
"name": "llama",
"description": "llama.cpp MCP server for local LLM inference",
"source": "./plugins/llama"
}
]
}
Step 3: Create plugin.json
// llama-marketplace/plugins/llama/.claude-plugin/plugin.json
{
"name": "llama",
"version": "0.1.0",
"description": "llama.cpp MCP server for local LLM inference"
}
Step 4: Create .mcp.json
// llama-marketplace/plugins/llama/.mcp.json
{
"mcpServers": {
"llama": {
"command": "npx",
"args": ["-y", "llama-mcp-server"],
"env": {
"LLAMA_SERVER_URL": "http://localhost:8080",
"LLAMA_MODEL_PATH": "/path/to/your/model.gguf",
"LLAMA_SERVER_PATH": "/path/to/llama-server"
}
}
}
}
Step 5: Install the plugin
# Add the local marketplace
claude plugin marketplace add /path/to/llama-marketplace
# Install the plugin
claude plugin install llama@llama-marketplace
# Restart Claude Code
After restart, tools will appear as mcp__plugin_llama_llama__*.
Option 2: Direct MCP Configuration
Note: This method may not work due to the bug mentioned above. If tools don't appear after adding the server, use Option 1.
Add to your Claude Code MCP configuration:
claude mcp add llama -e LLAMA_SERVER_URL=http://localhost:8080 -e LLAMA_MODEL_PATH=/path/to/model.gguf -e LLAMA_SERVER_PATH=/path/to/llama-server -- npx -y llama-mcp-server
Or add manually to ~/.claude.json:
{
"mcpServers": {
"llama": {
"command": "npx",
"args": ["-y", "llama-mcp-server"],
"env": {
"LLAMA_SERVER_URL": "http://localhost:8080",
"LLAMA_MODEL_PATH": "/path/to/your/model.gguf",
"LLAMA_SERVER_PATH": "/path/to/llama-server"
}
}
}
}
Tools
Server Tools
| Tool | Description |
|---|---|
llama_health |
Check if llama-server is running and get status |
llama_props |
Get or set server properties |
llama_models |
List available/loaded models |
llama_slots |
View current slot processing state |
llama_metrics |
Get Prometheus-compatible metrics |
Token Tools
| Tool | Description |
|---|---|
llama_tokenize |
Convert text to token IDs |
llama_detokenize |
Convert token IDs back to text |
llama_apply_template |
Format chat messages using model's template |
Inference Tools
| Tool | Description |
|---|---|
llama_complete |
Generate text completion from a prompt |
llama_chat |
Chat completion (OpenAI-compatible) |
llama_embed |
Generate embeddings for text |
llama_infill |
Code completion with prefix and suffix context |
llama_rerank |
Rerank documents by relevance to a query |
Model Management Tools
| Tool | Description |
|---|---|
llama_load_model |
Load a model (router mode only) |
llama_unload_model |
Unload the current model (router mode only) |
LoRA Tools
| Tool | Description |
|---|---|
llama_lora_list |
List loaded LoRA adapters |
llama_lora_set |
Set LoRA adapter scales |
Process Control Tools
| Tool | Description |
|---|---|
llama_start |
Start llama-server as a child process |
llama_stop |
Stop the llama-server process |
Example: Starting llama-server and Running Inference
User: Start llama-server with my local model
Claude: I'll start llama-server for you.
[Uses llama_start tool with model path]
User: Generate a haiku about coding
Claude: Let me use the local model for that.
[Uses llama_complete tool]
Result:
Lines of code cascade
Through the silent morning hours
Bugs flee from the light
Development
# Run tests
npm test
# Type check
npm run typecheck
# Build
npm run build
# Watch mode for development
npm run dev
Troubleshooting
Tools don't appear in Claude Code
Symptom: Server shows "Connected" in claude mcp list but no llama_* tools are available.
Cause: Known bug in Claude Code where non-plugin MCP servers don't expose tools (#12164).
Solution: Use the plugin installation method (Option 1 above).
HTTP 501 errors for certain tools
Some tools require specific server configurations:
| Tool | Requirement |
|---|---|
llama_metrics |
Start llama-server with --metrics flag |
llama_embed |
Start llama-server with --embedding flag or use an embedding model |
llama_infill |
Use a model with fill-in-middle support (e.g., CodeLlama, DeepSeek Coder) |
llama_rerank |
Use a reranker model |
llama_load_model / llama_unload_model |
llama-server must be in router mode |
Connection refused errors
Symptom: Cannot connect to llama-server at http://localhost:8080
Solutions:
- Use
llama_startto start the server, or - Start llama-server manually:
llama-server -m /path/to/model.gguf - Check that
LLAMA_SERVER_URLmatches where llama-server is running
WSL/Windows path issues
When running in WSL, ensure paths use Linux format:
- ✓
/home/user/models/model.gguf - ✗
C:\Users\user\models\model.gguf
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。