Skip to content

Add dual transport support (SSE) to MCP server and LM-Studio integration#843

Closed
neodingo wants to merge 13 commits intocoleam00:mainfrom
neodingo:adding-sse
Closed

Add dual transport support (SSE) to MCP server and LM-Studio integration#843
neodingo wants to merge 13 commits intocoleam00:mainfrom
neodingo:adding-sse

Conversation

@neodingo
Copy link
Copy Markdown

@neodingo neodingo commented Nov 6, 2025

Summary

This PR adds dual transport support to the Archon MCP server for maximum client compatibility, along with LM-Studio integration for both chat and embedding capabilities.

Key Features

🔄 Dual Transport Support

  • Added Server-Sent Events (SSE) transport alongside stdio for MCP server
  • Enables MCP server to work with web-based clients and remote connections
  • Maintains backward compatibility with stdio-based clients
  • Includes test scripts for validation (test_dual_transport.sh, test_endpoints.sh)

🤖 LM-Studio Integration

  • Chat Provider: Full PydanticAI agent support for LM-Studio chat models
  • Embedding Provider: Local inference support for embeddings
  • UI integration with LM-Studio logo and settings
  • Comprehensive test suite (test_lmstudio_agent.py)

📚 Documentation Updates

  • Expanded MCP server documentation with dual transport configuration
  • Added comprehensive README for MCP server setup and usage
  • Updated CLAUDE.md to follow Archon task management rules

Changes

  • MCP Server: Enhanced with dual transport capability (stdio + SSE)
  • Agent System: LM-Studio chat provider integration
  • Embedding Service: LM-Studio local embedding support
  • UI Components: RAG settings updated with LM-Studio credential management
  • Documentation: Extensive updates to MCP server docs and configuration guides
  • Testing: New test scripts and agent tests for LM-Studio integration

Files Changed

  • 16 files changed
  • 1,092 additions
  • 309 deletions

Testing

  • ✅ Dual transport test script included
  • ✅ LM-Studio agent tests included
  • ✅ API endpoint tests included

Branch sync: This branch includes merges from main/stable with updates to release workflows, README improvements, and agent mode enhancements.

Summary by CodeRabbit

  • New Features

    • Added LM-Studio as a supported LLM provider with local base URL configuration
    • Implemented dual transport support (Streamable HTTP and SSE) for MCP server with environment toggles
  • Documentation

    • Updated MCP server configuration guide with transport selection and client setup examples
    • Added MCP Server setup documentation covering both transports and troubleshooting
  • Tests

    • Added LM-Studio provider integration tests
    • Added transport validation test scripts

coleam00 and others added 13 commits October 11, 2025 07:16
0.1.0 release of Archon! Improvements across the board to crawling speed and reliability, RAG strategies, docs, task management, and documentation.
Release workflow update for Archon 0.1.0 release.
Adjusting permissions in release note workflow for Archon 0.1.0 release
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implements LM-Studio integration as a new embedding provider option,
enabling users to run embeddings locally without API keys. This extends
the existing provider ecosystem (OpenAI, Google, Ollama) with another
self-hosted alternative.

Backend changes:
- Add lmstudio to allowed providers list in knowledge API validation
- Extend credential service to handle lmstudio (no API key required)
- Configure default base URL: http://host.docker.internal:1234/v1
- Add lmstudio-specific embedding model validation patterns
- Include default models: text-embedding-nomic-embed-text and variants
- Support local model detection (embed, nomic, all-minilm, bge, gte)

Frontend changes:
- Add LM-Studio provider card in RAG Settings with indigo color scheme
- Include LM-Studio logo (SVG) in provider selection grid
- Mark as embedding-capable provider alongside OpenAI, Google, Ollama
- Set default models: llama-3.2-1b-instruct (chat), text-embedding-nomic-embed-text (embedding)
- Add LMSTUDIO_BASE_URL to credentials service schema
- Handle lmstudio as configured by default (local service, no key check)

Technical details:
- Uses OpenAI-compatible API endpoints (similar to Ollama pattern)
- No authentication required for local instances
- Default port 1234 with Docker host.docker.internal routing
- Supports common embedding models available in LM-Studio ecosystem

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Enable PydanticAI agents (RAG, Document, etc.) to use LM-Studio as a chat provider through the "lmstudio:model-name" format. This completes the LM-Studio integration that was already present in the embedding and credential services.

Changes:
- Add _prepare_model_for_agent() helper to detect and handle lmstudio: prefix
- Create custom AsyncOpenAI client with LM-Studio base URL
- Return OpenAIChatModel configured for PydanticAI compatibility
- Support LM_STUDIO_BASE_URL env var (defaults to http://host.docker.internal:1234/v1)
- Maintain backward compatibility for all existing providers
- Add comprehensive test suite in tests/test_lmstudio_agent.py

Usage: agent = RagAgent(model="lmstudio:llama-3.2-1b-instruct")

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…lity

Implements both Streamable HTTP (/mcp) and SSE (/sse) transports to support
modern and legacy MCP clients. This enables smooth migration from deprecated
SSE to the modern Streamable HTTP transport (MCP protocol 2025-03-26) while
maintaining backward compatibility with existing integrations.

Implementation:
- Modified mcp_server.py to combine routes from both streamable_http_app()
  and sse_app() using shared FastMCP instance and lifespan context
- Added environment variables ARCHON_MCP_ENABLE_STREAMABLE_HTTP and
  ARCHON_MCP_ENABLE_SSE (both default to true)
- Updated mcp_api.py to return transport_endpoints array with both endpoints
- Added comprehensive configuration guide (python/src/mcp_server/README.md)
- Updated docs/docs/mcp-server.mdx with dual transport documentation and
  client configuration examples for Claude Code, Cursor, and Windsurf

Testing:
- Both transports verified functional on isolated test port (8060)
- Manual client compatibility testing completed
- Production MCP server (port 8051) confirmed untouched during development

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR adds dual-transport MCP server support (Streamable HTTP and SSE) configurable via environment variables, integrates LM-Studio as a new local LLM provider across UI and backend services, updates server configuration endpoints to reflect transport capabilities, and provides comprehensive documentation and test scripts for the new transport architecture.

Changes

Cohort / File(s) Summary
MCP Dual Transport Configuration
.env.example, docs/docs/mcp-server.mdx
Added environment variables ARCHON_MCP_ENABLE_STREAMABLE_HTTP and ARCHON_MCP_ENABLE_SSE to control transport protocols; documented transport selection, usage guidance, and migration notes.
MCP Server Implementation
python/src/mcp_server/mcp_server.py, python/src/mcp_server/README.md
Implemented dual-transport assembly logic with validation requiring at least one transport enabled; new README documents transport configuration, client setup (Claude Code, Cursor, Windsurf), troubleshooting, and development guidance.
MCP Configuration Endpoints
python/src/server/api_routes/mcp_api.py
Updated MCP config endpoint to derive transport settings from environment, return transport_endpoints and enabled_transports fields, and select primary transport dynamically.
LM-Studio Frontend Integration
archon-ui-main/src/components/settings/RAGSettings.tsx, archon-ui-main/src/services/credentialsService.ts
Added lmstudio as a new ProviderKey with default models, color styling, display name, logo, and status handling; extended RagSettings interface with LMSTUDIO_BASE_URL field.
LM-Studio Backend Provider Support
python/src/agents/base_agent.py, python/src/server/api_routes/knowledge_api.py, python/src/server/services/credential_service.py, python/src/server/services/llm_provider_service.py
Added lmstudio to provider validation, credential mapping, and embedding model selection; implemented _prepare_model_for_agent() to configure AsyncOpenAI client for LM-Studio; added LM-Studio embedding models and base URL handling.
Testing & Scripts
python/tests/test_lmstudio_agent.py, test_dual_transport.sh, test_endpoints.sh
New test module validates LM-Studio model preparation and agent instantiation; shell scripts test dual-transport setup and verify HTTP/SSE/config endpoints.
Documentation
CLAUDE.md
Rewritten to emphasize task-driven Archon MCP workflow, replacing legacy development commands with task management and RAG tools; updated architecture references and development guidance.

Sequence Diagram

sequenceDiagram
    participant Client
    participant MCP Server
    participant ASGI App
    participant Streamable HTTP
    participant SSE Handler

    Client->>MCP Server: Initialize
    MCP Server->>MCP Server: Read env vars<br/>(ENABLE_STREAMABLE_HTTP,<br/>ENABLE_SSE)
    
    alt Both Enabled (Dual Transport)
        MCP Server->>Streamable HTTP: Create app at /mcp
        MCP Server->>SSE Handler: Attach routes at /sse
        MCP Server->>ASGI App: Combined app ready
    else Only Streamable HTTP
        MCP Server->>Streamable HTTP: Create app at /mcp
        MCP Server->>ASGI App: HTTP-only app ready
    else Only SSE
        MCP Server->>SSE Handler: Create SSE app
        MCP Server->>ASGI App: SSE-only app ready
    end
    
    MCP Server->>MCP Server: Start uvicorn server
    MCP Server->>Client: Ready on port 8060
    
    Client->>MCP Server: GET /mcp (HTTP)
    MCP Server->>Streamable HTTP: Route
    Streamable HTTP->>Client: Response
    
    Client->>MCP Server: GET /sse (SSE)
    MCP Server->>SSE Handler: Route
    SSE Handler->>Client: Event stream
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • MCP dual-transport logic (python/src/mcp_server/mcp_server.py, python/src/server/api_routes/mcp_api.py): Requires careful review of configuration validation, transport selection, and endpoint assembly.
  • LM-Studio provider integration: Follows established patterns but spans multiple files (RAGSettings.tsx, base_agent.py, llm_provider_service.py, etc.); consistency of default models, base URL handling, and type definitions should be verified across layers.
  • Test coverage: Verify test_lmstudio_agent.py adequately covers model preparation and agent instantiation paths.
  • Environment configuration: Ensure .env.example and documentation align with actual env var usage in mcp_server.py and mcp_api.py.

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • coleam00
  • leex279
  • tazmon95

Poem

🐰 Two transports dance, both swift and bright,
Streamable and SSE in tandem flight!
LM-Studio joins the provider choir,
Dual-path routing takes configs higher. ✨
Archon MCP now speaks in stereo—
One server, two voices, full maestro! 🎼

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 987c874 and c109f3f.

⛔ Files ignored due to path filters (1)
  • archon-ui-main/public/img/LM-Studio.svg is excluded by !**/*.svg
📒 Files selected for processing (15)
  • .env.example (1 hunks)
  • CLAUDE.md (1 hunks)
  • archon-ui-main/src/components/settings/RAGSettings.tsx (9 hunks)
  • archon-ui-main/src/services/credentialsService.ts (3 hunks)
  • docs/docs/mcp-server.mdx (2 hunks)
  • python/src/agents/base_agent.py (2 hunks)
  • python/src/mcp_server/README.md (1 hunks)
  • python/src/mcp_server/mcp_server.py (2 hunks)
  • python/src/server/api_routes/knowledge_api.py (1 hunks)
  • python/src/server/api_routes/mcp_api.py (3 hunks)
  • python/src/server/services/credential_service.py (2 hunks)
  • python/src/server/services/llm_provider_service.py (5 hunks)
  • python/tests/test_lmstudio_agent.py (1 hunks)
  • test_dual_transport.sh (1 hunks)
  • test_endpoints.sh (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@neodingo neodingo closed this Nov 6, 2025
coleam00 pushed a commit that referenced this pull request Apr 7, 2026
…nd types (step 2.2) (#855)

* refactor(schemas): connect server schemas to engine Zod schemas + generate frontend types (step 2.2)

Replace z.any() in workflowDefinitionSchema with the real engine schema imported
via direct subpath (@archon/workflows/schemas/workflow). The OpenAPI spec at
/api/openapi.json now describes the full workflow definition structure (name,
description, provider, model, etc.) instead of a bare {} object.

Add openapi-typescript as a devDep in @archon/web and generate api.generated.d.ts
from the live spec. Update workflow-types.ts to derive WorkflowRunStatus and the
WorkflowDefinition base fields from the generated types; DagNode-related types
remain hand-written (nodes is z.array(z.any()) by design in the engine schema —
per-node validation happens in loader.ts, not at the top level).

Add **/*.generated.d.ts to the ESLint global ignores so auto-generated
declaration files are not linted.

Closes #843

* docs+test: address review feedback on schema codegen PR

- Update CLAUDE.md @archon/web bullet to clarify that WorkflowRunStatus
  and WorkflowDefinition base fields are derived from api.generated.d.ts
  (not a manual mirror); DagNode and variants remain hand-written
- Update CLAUDE.md import patterns comment to distinguish generated vs
  hand-written types instead of calling the whole file a "local mirror"
- Add generate:types prerequisite note (server must be running at :3090)
  to the Development section of CLAUDE.md
- Fix TRIGGER_RULES comment in workflow-types.ts to make explicit it is
  a manual copy that must be kept in sync with triggerRuleSchema.options
- Add prompt?: never omission comment to WorkflowDefinition in
  workflow-types.ts to document the deliberate structural difference
- Add schema-shape assertion to api.workflows.test.ts that verifies
  GET /api/workflows/:name returns name, description, and nodes fields,
  guarding against silent spec drift from future engine schema changes
Tyone88 pushed a commit to Tyone88/Archon that referenced this pull request Apr 16, 2026
…nd types (step 2.2) (coleam00#855)

* refactor(schemas): connect server schemas to engine Zod schemas + generate frontend types (step 2.2)

Replace z.any() in workflowDefinitionSchema with the real engine schema imported
via direct subpath (@archon/workflows/schemas/workflow). The OpenAPI spec at
/api/openapi.json now describes the full workflow definition structure (name,
description, provider, model, etc.) instead of a bare {} object.

Add openapi-typescript as a devDep in @archon/web and generate api.generated.d.ts
from the live spec. Update workflow-types.ts to derive WorkflowRunStatus and the
WorkflowDefinition base fields from the generated types; DagNode-related types
remain hand-written (nodes is z.array(z.any()) by design in the engine schema —
per-node validation happens in loader.ts, not at the top level).

Add **/*.generated.d.ts to the ESLint global ignores so auto-generated
declaration files are not linted.

Closes coleam00#843

* docs+test: address review feedback on schema codegen PR

- Update CLAUDE.md @archon/web bullet to clarify that WorkflowRunStatus
  and WorkflowDefinition base fields are derived from api.generated.d.ts
  (not a manual mirror); DagNode and variants remain hand-written
- Update CLAUDE.md import patterns comment to distinguish generated vs
  hand-written types instead of calling the whole file a "local mirror"
- Add generate:types prerequisite note (server must be running at :3090)
  to the Development section of CLAUDE.md
- Fix TRIGGER_RULES comment in workflow-types.ts to make explicit it is
  a manual copy that must be kept in sync with triggerRuleSchema.options
- Add prompt?: never omission comment to WorkflowDefinition in
  workflow-types.ts to document the deliberate structural difference
- Add schema-shape assertion to api.workflows.test.ts that verifies
  GET /api/workflows/:name returns name, description, and nodes fields,
  guarding against silent spec drift from future engine schema changes
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
…nd types (step 2.2) (coleam00#855)

* refactor(schemas): connect server schemas to engine Zod schemas + generate frontend types (step 2.2)

Replace z.any() in workflowDefinitionSchema with the real engine schema imported
via direct subpath (@archon/workflows/schemas/workflow). The OpenAPI spec at
/api/openapi.json now describes the full workflow definition structure (name,
description, provider, model, etc.) instead of a bare {} object.

Add openapi-typescript as a devDep in @archon/web and generate api.generated.d.ts
from the live spec. Update workflow-types.ts to derive WorkflowRunStatus and the
WorkflowDefinition base fields from the generated types; DagNode-related types
remain hand-written (nodes is z.array(z.any()) by design in the engine schema —
per-node validation happens in loader.ts, not at the top level).

Add **/*.generated.d.ts to the ESLint global ignores so auto-generated
declaration files are not linted.

Closes coleam00#843

* docs+test: address review feedback on schema codegen PR

- Update CLAUDE.md @archon/web bullet to clarify that WorkflowRunStatus
  and WorkflowDefinition base fields are derived from api.generated.d.ts
  (not a manual mirror); DagNode and variants remain hand-written
- Update CLAUDE.md import patterns comment to distinguish generated vs
  hand-written types instead of calling the whole file a "local mirror"
- Add generate:types prerequisite note (server must be running at :3090)
  to the Development section of CLAUDE.md
- Fix TRIGGER_RULES comment in workflow-types.ts to make explicit it is
  a manual copy that must be kept in sync with triggerRuleSchema.options
- Add prompt?: never omission comment to WorkflowDefinition in
  workflow-types.ts to document the deliberate structural difference
- Add schema-shape assertion to api.workflows.test.ts that verifies
  GET /api/workflows/:name returns name, description, and nodes fields,
  guarding against silent spec drift from future engine schema changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants