Skip to content

feat: add MCP server for AI agent integration#1866

Open
basgcorp wants to merge 1 commit intosession-foundation:devfrom
basgcorp:dev
Open

feat: add MCP server for AI agent integration#1866
basgcorp wants to merge 1 commit intosession-foundation:devfrom
basgcorp:dev

Conversation

@basgcorp
Copy link

Summary

  • Adds a Model Context Protocol (MCP) server that enables AI agents to interact with Session Desktop programmatically
  • Introduces ts/mcp/ module with SSE-based MCP server, webhook manager, IPC handlers, and renderer bridge
  • Supports background mode (--background / SESSION_MCP_BACKGROUND=1) for headless operation
  • Hooks into the message receive pipeline to dispatch real-time new message events via webhooks
  • Adds @modelcontextprotocol/sdk dependency
  • Includes integration, unit, and webhook test suites

Details

New module ts/mcp/:

  • server.ts — HTTP+SSE MCP server with optional token auth, configurable via SESSION_MCP_PORT, SESSION_MCP_HOST, SESSION_MCP_TOKEN
  • webhookManager.ts — manages webhook subscriptions and dispatches message events
  • messageEventHook.ts — bridges message pipeline to MCP event system
  • rendererHandlers.ts — IPC handler initialization for renderer process
  • types.ts — shared MCP types and IPC channel definitions

Modified files:

  • ts/mains/main_node.ts — MCP server lifecycle, background mode, IPC setup
  • ts/receiver/queuedJob.ts — new message event hook for webhook dispatch
  • preload.js — MCP renderer handler initialization

Test plan

  • Verify MCP server starts on default port 6274 and responds to SSE connections
  • Verify background mode hides window and keeps app alive
  • Verify incoming messages trigger webhook notifications
  • Verify optional token auth blocks unauthorized requests
  • Run test-mcp.mjs, test-mcp-integration.mjs, test-webhook.mjs

- Add @modelcontextprotocol/sdk and human-signals dependencies
- Create ts/mcp/ module with server, types, webhooks, renderer handlers
- Add background mode support via --background flag and SESSION_MCP_BACKGROUND env
- Hook message receive pipeline for webhook event notifications
- Initialize MCP renderer handlers in preload.js
- Add MCP IPC handler setup and server startup in main_node.ts
- Add test files for MCP server, integration, and webhooks
- Update version to 1.17.12-mcp
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.

1 participant