feat: Enhance MCP service configuration with stdio transport support

- Added support for stdio transport type in MCP service configuration, allowing command execution via standard input/output.
- Updated MCPService interface to include optional stdio_config and env_vars fields for managing command arguments and environment variables.
- Enhanced frontend components to handle stdio transport, including dynamic form fields for command and arguments.
- Implemented validation logic for stdio configuration in the service update process, ensuring proper handling of required fields.
- Updated backend logic to manage stdio transport connections and ensure proper client lifecycle management.
This commit is contained in:
wizardchen
2025-11-12 11:32:59 +08:00
parent 3c02c4a434
commit 05154c8d75
15 changed files with 631 additions and 23 deletions
@@ -0,0 +1,19 @@
-- 06-add-mcp-stdio-support.sql
-- Add stdio transport support for MCP services
-- Add stdio_config and env_vars columns
ALTER TABLE mcp_services
ADD COLUMN stdio_config JSON COMMENT 'Stdio configuration: {command: "uvx"/"npx", args: [...]}',
ADD COLUMN env_vars JSON COMMENT 'Environment variables for stdio transport';
-- Make url column optional (remove NOT NULL constraint)
ALTER TABLE mcp_services
MODIFY COLUMN url VARCHAR(512) NULL;
-- Add check constraint: stdio transport requires stdio_config, others require url
ALTER TABLE mcp_services
ADD CONSTRAINT chk_mcp_transport_config CHECK (
(transport_type = 'stdio' AND stdio_config IS NOT NULL) OR
(transport_type != 'stdio' AND url IS NOT NULL)
);
@@ -0,0 +1,19 @@
-- 06-add-mcp-stdio-support.sql
-- Add stdio transport support for MCP services
-- Add stdio_config and env_vars columns
ALTER TABLE mcp_services
ADD COLUMN IF NOT EXISTS stdio_config JSONB, -- Stdio configuration: {command: "uvx"/"npx", args: [...]}
ADD COLUMN IF NOT EXISTS env_vars JSONB; -- Environment variables for stdio transport
-- Make url column optional (remove NOT NULL constraint)
ALTER TABLE mcp_services
ALTER COLUMN url DROP NOT NULL;
-- Add check constraint: stdio transport requires stdio_config, others require url
ALTER TABLE mcp_services
ADD CONSTRAINT chk_mcp_transport_config CHECK (
(transport_type = 'stdio' AND stdio_config IS NOT NULL) OR
(transport_type != 'stdio' AND url IS NOT NULL)
);
@@ -0,0 +1,20 @@
-- 06-add-mcp-stdio-support.sql
-- Rollback stdio transport support for MCP services
BEGIN;
-- Remove check constraint
ALTER TABLE mcp_services
DROP CONSTRAINT IF EXISTS chk_mcp_transport_config;
-- Make url column required again
ALTER TABLE mcp_services
ALTER COLUMN url SET NOT NULL;
-- Remove stdio_config and env_vars columns
ALTER TABLE mcp_services
DROP COLUMN IF EXISTS env_vars,
DROP COLUMN IF EXISTS stdio_config;
COMMIT;
@@ -0,0 +1,23 @@
-- 06-add-mcp-stdio-support.sql
-- Add stdio transport support for MCP services
BEGIN;
-- Add stdio_config and env_vars columns
ALTER TABLE mcp_services
ADD COLUMN IF NOT EXISTS stdio_config JSONB, -- Stdio configuration: {command: "uvx"/"npx", args: [...]}
ADD COLUMN IF NOT EXISTS env_vars JSONB; -- Environment variables for stdio transport
-- Make url column optional (remove NOT NULL constraint)
ALTER TABLE mcp_services
ALTER COLUMN url DROP NOT NULL;
-- Add check constraint: stdio transport requires stdio_config, others require url
ALTER TABLE mcp_services
ADD CONSTRAINT chk_mcp_transport_config CHECK (
(transport_type = 'stdio' AND stdio_config IS NOT NULL) OR
(transport_type != 'stdio' AND url IS NOT NULL)
);
COMMIT;