Skip to main content
Glama
JacobRyu
by JacobRyu

Custom MCP Server

A custom MCP (Model Control Proxy) server that sits between clients and an OpenAI-compatible chat-completion backend. It provides:

  • Input validation, normalization, and chunking

  • Session-based conversational memory (in-memory store, swappable)

  • Sliding-window context management with rough token capping

  • Prompt construction with injectable system instructions

  • Resilient async agent calls (timeout + single retry on 429/5xx)

This is the MVP scope (milestones M1 + M2). Streaming, real summarization, persistent stores, and auth are deferred.

Requirements

  • Python 3.11+

  • uv (package & environment manager)

Related MCP server: MCP Server with LLM Integration

Install

uv sync --all-extras
# activate the environment
source .venv/bin/activate

Configure

cp .env.example .env
# edit .env and set AGENT_API_KEY, AGENT_API_BASE_URL, AGENT_MODEL

Run

uv run uvicorn app.main:app --reload --port 8000

Endpoints

POST /agent/input

curl -s http://localhost:8000/agent/input \
  -H 'Content-Type: application/json' \
  -d '{"user_input": "Hello!"}'

GET /session/{id}

curl -s http://localhost:8000/session/<session_id>

DELETE /session/{id}

curl -X DELETE http://localhost:8000/session/<session_id>

GET /health

curl -s http://localhost:8000/health

Test

uv run pytest -q

Layout

app/
  main.py              FastAPI app, logging, health
  config.py            Settings (pydantic-settings)
  api/                 HTTP routers
  models/schemas.py    Pydantic request/response models
  core/                input_processor, context_manager, prompt_builder, agent_client
  storage/             SessionStore protocol + in-memory implementation
  utils/               logging + token estimation
tests/                 pytest suite (agent backend mocked)
docs/                  Design documentation (architecture, data model, API, ADRs)

Design documentation

See docs/ for the full design package:

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    High-performance Model Context Protocol server supporting multiple LLM providers (OpenRouter, OpenAI, Groq) with WebSocket API and conversation history persistence.
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables chat with multiple LLM providers (OpenAI and Anthropic) while maintaining persistent conversation memory. Provides extensible tool framework for various operations including echo functionality and conversation storage/retrieval.
    MIT