LL

LLM Analysis Assistant MCP Server Logs and Simulation

Monitor MCP server activity and simulate Ollama/OpenAI interfaces with a streamlined client supporting stdio, SSE, streamableHttp and /logs.

Overview

This MCP (Model Context Protocol) server provides a focused toolset for monitoring model interactions and for emulating common model-hosting interfaces (Ollama/OpenAI-style) during development and testing. It captures MCP events, exposes a simple logs API, and offers multiple streaming transports (stdio, Server-Sent Events, chunked HTTP) so you can test client integrations that expect streaming model output or need to replay past interactions.

The server is useful when building or diagnosing LLM integrations: you can run your client against an environment that behaves like Ollama/OpenAI, inspect structured MCP logs, and reproduce streaming behavior without invoking external LLM hosts. The project repository is at https://github.com/xuzexin-hz/llm-analysis-assistant.

Features

  • MCP-aware server that records model-context protocol events and metadata
  • Emulates Ollama/OpenAI HTTP endpoints so existing clients can point at it
  • Multiple streaming transports:
    • stdio mode for local CLI clients
    • SSE (Server-Sent Events) for browser or long-lived HTTP clients
    • streamable HTTP (chunked transfer) for typical streaming endpoints
  • /logs endpoint to query recent MCP events or full session logs
  • Lightweight configuration via environment variables or JSON config file
  • Useful for local development, integration tests, and debugging

Installation / Configuration

Clone the repository and run using Docker or a local build. Example workflows:

Clone repository

git clone https://github.com/xuzexin-hz/llm-analysis-assistant.git
cd llm-analysis-assistant

Run with Docker (recommended for quick start)

# Build an image (if Dockerfile present) or run a provided image
docker build -t mcp-server .
docker run -p 8080:8080 -e PORT=8080 mcp-server

Run locally (example using a Go or Node binary)

# If the project produces a binary named mcp-server
./mcp-server --config config.json
# or, if it's a Node app
npm install
npm start

Example environment variables

export PORT=8080          # HTTP port
export LOG_PATH=./mcp.log # optional file path for persistent logs
export MAX_LOGS=1000      # max number of log entries kept in memory
export SIMULATE_OLLAMA=true

Example minimal config.json

{
  "port": 8080,
  "maxLogEntries": 1000,
  "logPath": "./mcp.log",
  "simulateOllama": true,
  "simulateOpenAI": true
}

Available Resources

Endpoints and transports commonly available from this server (adjust host/port as configured):

Endpoint / TransportPurpose
GET /logs?limit=NReturn last N MCP log entries (JSON)
POST /v1/chat/completionsOpenAI-compatible endpoint (sync/async)
POST /ollama/generateOllama-compatible generation endpoint
GET /streamSSE stream of live MCP events
POST /streamableHTTP chunked response for streaming clients
stdioStart the server in stdio mode to accept MCP messages over STDIN / write responses to STDOUT

Log format (JSON lines) typically contains fields such as:

  • timestamp
  • sessionId
  • eventType (request/response/token/log)
  • payload (structured MCP content)

Refer to the repo README for exact event fields if you need to map events to your telemetry.

Use Cases

  1. Local development and integration testing

    • Point your application (that normally calls OpenAI/Ollama) to the MCP server’s OpenAI/Ollama-compatible endpoints. Validate behavior when the server streams partial tokens or emits metadata events without touching a real model provider.

    Example:

    curl -N -X POST http://localhost:8080/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{"model":"mcp-test","messages":[{"role":"user","content":"Hello"}]}'
    
  2. Debug streaming behavior

    • Use the SSE endpoint to observe token-level events emitted by your client/server stack and verify reconnection, resumption, and event ordering.

    SSE example:

    curl -N http://localhost:8080/stream
    
  3. Replay and auditing

    • Use the /logs API to fetch recent interactions when diagnosing model hallucinations or unexpected outputs. You can export logs and replay sequences through the simulated endpoints.

    Fetch last 50 logs:

    curl http://localhost:8080/logs?limit=50
    
  4. CLI-driven workflows

    • Run the server in stdio mode to wire it into local toolchains and test stdin/stdout-based adapters that many LLM clients use for lightweight integrations.

    Example (sending a JSON request via STDIN):

    printf '{"type":"request","body":{"prompt":"Hello"}}\n' | ./mcp-client --stdio
    

Tips for Developers

  • Map the server’s log schema to your observability tools (Datadog, Loki, etc.) by forwarding /logs output or writing the configured logPath to disk.
  • Use the streamable HTTP and SSE transports to ensure your UI handles partial updates and reconnections gracefully.
  • Keep MAX_LOGS configured appropriately in production simulations to avoid unbounded memory growth.

For more details and the exact API shape, see the project repository: https://github.com/xuzexin-hz/llm-analysis-assistant.