Skip to main content

lexigram-ai-mcp

MCP Server for Lexigram Framework - Model Context Protocol server for AI agents


Overview

Model Context Protocol (MCP) server and client implementation for the Lexigram Framework. Exposes tools, resources, and prompts to any MCP-compatible client — including Claude Desktop, Cursor, and custom AI agents — over SSE or stdio transports. Also provides MCP client connectivity for consuming external MCP servers. Zero-config usage starts with sensible defaults.

Full documentation: docs.lexigram.dev

Install

uv add lexigram-ai-mcp

Quick Start

from lexigram import Application
from lexigram.di.module import Module, module

from lexigram.ai.mcp import MCPModule
from lexigram.ai.mcp.config import MCPConfig


@module(
    imports=[
        MCPModule.configure(
            config=MCPConfig(
                server_name="my-app",
                server_version="1.0.0",
                enable_sse=True,
                stdio_mode=False,
            )
        )
    ]
)
class AppModule(Module):
    pass


async with Application.boot(modules=[AppModule]) as app:
    # use app.container to resolve services
    ...

Note: Full-module boot is currently limited — MCPModule registers handlers during the boot phase, which the container freeze (LEX_ERR_DI_001) prevents. Use Application.boot for other modules; for MCP, resolve controllers/services directly from the container (container.resolve(MyController)) in tests.

Configuration

Zero-config usage: Call MCPModule.configure() with no arguments to use defaults.

Option 1 — YAML file

# application.yaml
ai_mcp:
  host: "0.0.0.0"
  port: 8080
  path: "/mcp"
  enable_sse: true
  server_name: "lexigram-mcp"
  server_version: "1.0.0"

Option 2 — Profiles + Environment Variables (recommended)

export LEX_AI_MCP__ENABLED=true
export LEX_AI_MCP__HOST=0.0.0.0
# Environment variables for each field

Option 3 — Python

from lexigram.ai.mcp.config import MCPConfig
from lexigram.ai.mcp import MCPModule

config = MCPConfig(
    enabled=True,
    host="0.0.0.0",
    port=8080,
    enable_sse=True,
    server_name="my-app",
)
MCPModule.configure(config)

Config reference

Field Default Env var Description
enabled True LEX_AI_MCP__ENABLED Enable the MCP server subsystem
host "0.0.0.0" LEX_AI_MCP__HOST Host to bind (HTTP transport)
port 8080 LEX_AI_MCP__PORT Port to bind (HTTP transport)
path "/mcp" LEX_AI_MCP__PATH URL path for MCP endpoint
enable_sse True LEX_AI_MCP__ENABLE_SSE Enable Server-Sent Events transport
stdio_mode False LEX_AI_MCP__STDIO_MODE Use stdio transport instead of HTTP
server_name "lexigram-mcp" LEX_AI_MCP__SERVER_NAME MCP server name
server_version "1.0.0" LEX_AI_MCP__SERVER_VERSION MCP server version
cors_origins [] LEX_AI_MCP__CORS_ORIGINS CORS allowed origins
max_request_size 1048576 LEX_AI_MCP__MAX_REQUEST_SIZE Max request size (bytes)
request_timeout 30.0 LEX_AI_MCP__REQUEST_TIMEOUT Request timeout (seconds)

Module Factory Methods

Method Description
MCPModule.configure(config, controllers, services) Configure with explicit config
MCPModule.from_services(services, include_methods) Auto-expose service methods as MCP tools
MCPModule.stub() Minimal config for testing
MCPClientModule.configure(connections) Configure MCP client connections

Key Features

  • Server: Define tools using decorators (@tool, @resource, @prompt)
  • Controllers: Group related tools via MCPController
  • Auto-expose: Wire service methods as MCP tools
  • Transports: SSE and stdio transport support
  • Built-in connectors: Filesystem, GitHub, WebFetch, WebSearch, Slack, GoogleDrive, SQL
  • Client: Connect to external MCP servers
  • Adapters: Bridge to lexigram-ai-agents and lexigram-ai-skills

Testing

async with Application.boot(modules=[MCPModule.stub()]) as app:
    # your test code
    ...

Key Source Files

File What it contains
src/lexigram/ai/mcp/module.py MCPModule.configure(), from_services(), stub()
src/lexigram/ai/mcp/config.py MCPConfig and connector config classes
src/lexigram/ai/mcp/server/core.py MCPServer — protocol implementation
src/lexigram/ai/mcp/client/module.py MCPClientModule.configure()
src/lexigram/ai/mcp/transport/sse.py SSE transport (HTTP-based)
src/lexigram/ai/mcp/transport/stdio.py Stdio transport (subprocess-based)
src/lexigram/ai/mcp/controllers/base.py MCPController base class
src/lexigram/ai/mcp/di/provider.py MCPProvider — registers MCP into DI

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lexigram_ai_mcp-0.1.5002.tar.gz (106.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lexigram_ai_mcp-0.1.5002-py3-none-any.whl (105.3 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_ai_mcp-0.1.5002.tar.gz.

File metadata

  • Download URL: lexigram_ai_mcp-0.1.5002.tar.gz
  • Upload date:
  • Size: 106.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for lexigram_ai_mcp-0.1.5002.tar.gz
Algorithm Hash digest
SHA256 af57e90613131b414ed8656afd3efbd6d049cb69a5e9ae13d8fe77c2cfd6cb4c
MD5 854551c834aef2581e42ef846b912640
BLAKE2b-256 591fdd257ec608a4f1da58833925c13ee28e20752d8051d4f6dd2be239abc71c

See more details on using hashes here.

File details

Details for the file lexigram_ai_mcp-0.1.5002-py3-none-any.whl.

File metadata

File hashes

Hashes for lexigram_ai_mcp-0.1.5002-py3-none-any.whl
Algorithm Hash digest
SHA256 509c85c7afe21ed8864e9cce0ad0158a043d755db39c43e39bd123f700e8a3dc
MD5 7fc2134d16c5df24f6f51b3ae360ca36
BLAKE2b-256 b01646cca7f473ba08167eb65d868fa68b3f93d6fe5d1f10cdd529bd18dc2aff

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5009

1 file

0.1.5004

1 file

This release

0.1.5002 This release

2 files

0.1.5001

2 files

0.1.3007

1 file

0.1.3006

1 file

0.1.3005

1 file

0.1.4

2 files

0.1.2

1 file

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page