Skip to content

feat: auto-start API server when MCP server starts#23

Open
linhdmn wants to merge 1 commit intomainfrom
feature/mcp-auto-start-api
Open

feat: auto-start API server when MCP server starts#23
linhdmn wants to merge 1 commit intomainfrom
feature/mcp-auto-start-api

Conversation

@linhdmn
Copy link
Copy Markdown
Member

@linhdmn linhdmn commented Apr 21, 2026

Summary

  • MCP server (mcp-stdio) now automatically starts the REST API server if not already running
  • Simplifies workflow - users no longer need to manually start leankg api-serve
  • Uses port 9699 by default (configurable via LEANKG_API_PORT env var)
  • Auto-increments port if default is already in use

Test plan

  • leankg mcp-stdio starts API server automatically on port 9699
  • If API server already running, MCP detects and uses existing server
  • LEANKG_API_PORT=9000 leankg mcp-stdio uses specified port
  • API health check (curl localhost:9699/health) returns ok after MCP starts

When `leankg mcp-stdio` starts, it now checks if the REST API server
is running and starts it automatically if not. This simplifies the
workflow as users no longer need to manually start the API server.

Changes:
- Add is_api_server_running() to check port availability via TCP connect
- Add ensure_api_server_running() to spawn API server if not running
- Add find_available_port() to find next available port if default is taken
- Uses LEANKG_API_PORT env var or defaults to port 9699
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