Skip to main content
Glama

Local LLM MCP Server

A Model Context Protocol (MCP) server that provides Claude Code with specialized agents powered by local CUDA-accelerated LLMs. Each agent owns exactly one file and uses structured JSON-based tool calling for autonomous code generation.

Overview

This system enables Claude Code to orchestrate local agents that generate code using a local LLM (Qwen2.5-7B-Instruct). The architecture supports async task queueing, JSON-structured generation, and jinja2 template rendering for clean, executable Python code.

Key Features

  • πŸ€– Agent-based architecture: One agent per file, persistent per repository

  • ⚑ Async task queueing: Non-blocking tool calls with independent processing

  • πŸ“ JSON-structured generation: Metadata-driven code generation with jinja2 templates

  • πŸš€ CUDA acceleration: Optimized for RTX 1080ti with 15-25 tokens/second

  • πŸ”— MCP integration: Seamless Claude Code integration via HTTP/MCP bridge

  • βœ… 100% Success Rate: Working on tested examples with full implementations

Related MCP server: claude-delegate-local-mcp

Architecture

Claude Code β†’ HTTP/MCP β†’ Agent Registry β†’ Individual Agents β†’ Local LLM β†’ Tool Execution

Quick Start

Prerequisites

  • Ubuntu 22.04 with NVIDIA Driver 575+ and CUDA 12.9

  • Docker with NVIDIA Container Toolkit

  • Models directory: ~/models/Qwen2.5-7B-Instruct-Q6_K_L.gguf

Development Workflow

# Build and start server
inv build                  # Build Docker container with CUDA support
inv run --repo=<path>     # Start MCP server pointing to workspace
inv logs                  # View all container logs
inv logs --follow         # Follow logs in real-time
inv stop                  # Stop containers
inv test                  # Health check server
inv auth                  # Authenticate with server

# Example
inv run --repo=/home/user/Projects/local-llm-mcp/examples/CalculatorLocalModel

Features Demonstrated

  • βœ… Class definitions

  • βœ… Method implementations with parameters and return types

  • βœ… If/else conditional logic

  • βœ… Exception raising (ZeroDivisionError)

  • βœ… Type annotations

  • βœ… Docstrings

Tool System

Available Tools

  1. file_metadata - Creates structured JSON metadata for Python files

    • Actions: create_file, add_import, add_class, add_function, add_variable

    • Stores in .meta/*.json files

  2. workspace - File operations and code generation

    • Actions: read, write, delete, list, search, tree

    • generate_from_metadata - Renders Python from JSON metadata via jinja2

  3. validation - Code quality checks

    • Actions: tests, pre-commit, file-length, validate

  4. git_operations - Version control

    • Actions: status, diff, commit, log, branch

  5. agent_operations - Agent management

    • Actions: create, list, queue_task, task_status, task_result

Supported Operations

The operations field in file_metadata supports:

  • βœ… return - Return statement with value

  • βœ… assignment - Variable assignment

  • βœ… validation - Input validation with exceptions

  • βœ… function_call - Call other functions

  • βœ… if - Conditional logic with then/else branches

  • βœ… raise - Exception raising

  • ⏳ for/while - Loop operations (TODO)

  • ⏳ try/except - Error handling (TODO)

Agent Usage

Creating an Agent

# Via MCP tool
mcp__local-llm-agents__agent_operations({
    "operation": "create",
    "name": "CalculatorAgent",
    "description": "Expert in calculator functionality",
    "specialized_files": ["calculator.py"]
})

Queuing a Task

# Queue code generation task
mcp__local-llm-agents__agent_operations({
    "operation": "queue_task",
    "agent_id": "agent_id_here",
    "task_type": "code_generation",
    "message": "Create Calculator class with add, subtract, multiply, divide methods"
})

Checking Task Status

# Check if task completed
mcp__local-llm-agents__agent_operations({
    "operation": "task_status",
    "agent_id": "agent_id_here",
    "task_id": "task_id_here"
})

File Structure

local-llm-mcp/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ agents/          # Agent system
β”‚   β”‚   β”œβ”€β”€ llm/             # LLM management
β”‚   β”‚   β”œβ”€β”€ mcp/             # MCP bridge
β”‚   β”‚   β”œβ”€β”€ files/           # File manager
β”‚   β”‚   └── prompts/         # Prompt system
β”‚   β”œβ”€β”€ mcp/
β”‚   β”‚   └── tools/           # MCP tool implementations
β”‚   β”œβ”€β”€ schemas/             # Python file schemas
β”‚   └── api/                 # HTTP server
β”œβ”€β”€ templates/               # Jinja2 templates
β”œβ”€β”€ prompts/                 # Tool and system prompts
β”œβ”€β”€ examples/                # Working examples
β”‚   └── CalculatorLocalModel/  # Calculator demo
└── tests/                   # Test suite

License

[License information here]

Contributing

[Contributing guidelines here]

Contact

[Contact information here]

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables Claude Code to delegate agent tasks to local LLMs via llama.cpp or vLLM servers on your own hardware, reducing API usage while maintaining full agent capabilities.
      11
      22
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to hand scoped, implementation-only coding tasks to any model available in a local opencode install β€” including Kimi, GPT, Gemini and local models β€” and to run many of them in parallel. Claude stays the orchestrator: it briefs each worker, collects results and needs-flags, then reviews diffs and runs tests, lint and builds itself.
      1
      MIT