feat(workflow-as-mcp): wrapping workflows in the same workspace as MCP tools to particular MCP servers#2415
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR implements a comprehensive MCP (Model Context Protocol) server system that wraps deployed workflows as callable tools. The implementation adds infrastructure for users to create workspace-scoped MCP servers, register deployed workflows as tools, and expose them via standard MCP protocol endpoints for external clients. Key Changes:
Architecture: Security: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as MCP Client
participant ServeAPI as /api/mcp/serve/[serverId]
participant ExecAPI as /api/workflows/[id]/execute
participant DB as Database
participant Workflow as Workflow Engine
Note over Client,Workflow: MCP Tool Execution Flow
Client->>ServeAPI: POST tools/call {name, arguments}
ServeAPI->>ServeAPI: checkHybridAuth()
ServeAPI->>DB: Query workflow_mcp_tool by serverId + toolName
DB-->>ServeAPI: Return tool with workflowId
ServeAPI->>DB: Check workflow.isDeployed
DB-->>ServeAPI: Return deployment status
alt Workflow not deployed
ServeAPI-->>Client: Error: Workflow not deployed
else Workflow deployed
ServeAPI->>ExecAPI: POST /api/workflows/{workflowId}/execute<br/>{input: arguments, triggerType: 'mcp'}
ExecAPI->>Workflow: Execute workflow with input
Workflow-->>ExecAPI: Return execution result
ExecAPI-->>ServeAPI: Return {success, output}
ServeAPI-->>Client: JSONRPCResponse with result
end
Note over Client,Workflow: Tool Registration & Sync Flow
participant UI as Deploy UI
participant ToolAPI as /api/mcp/workflow-servers/[id]/tools
participant DeployAPI as /api/workflows/[id]/deploy
participant Sync as workflow-mcp-sync
UI->>ToolAPI: POST {workflowId, toolName, description}
ToolAPI->>DB: Verify workflow.isDeployed = true
ToolAPI->>DB: Verify hasValidStartBlock()
ToolAPI->>DB: Insert workflow_mcp_tool
DB-->>ToolAPI: Return created tool
ToolAPI-->>UI: Success
Note over DeployAPI,Sync: On workflow deploy/undeploy
DeployAPI->>Sync: syncMcpToolsForWorkflow()
Sync->>DB: Load workflow blocks
Sync->>Sync: Extract inputFormat from start block
Sync->>Sync: Generate parameter schema
Sync->>DB: Update workflow_mcp_tool.parameterSchema
DB-->>Sync: Schema updated
Sync-->>DeployAPI: Sync complete
|
apps/sim/app/api/workflows/[id]/deployments/[version]/revert/route.ts
Outdated
Show resolved
Hide resolved
apps/sim/app/api/mcp/workflow-servers/[id]/connection-info/route.ts
Outdated
Show resolved
Hide resolved
2f2ec02 to
2259bfc
Compare
|
@greptile |
…o feat/workflow-as-mcp
…rs and mcp tools (#2415) * added a workflow as mcp * fixed the issue of UI rendering for deleted mcp servers * fixing lint issues * using mcn components * fixing merge conflicts * fix * fix lint errors * refactored code to use hasstartblock from the tirgger utils * removing unecessary auth * using official mcp sdk and added description fields * using normalised input schema function * ui fixes part 1 * remove migration before merge * fix merge conflicts * remove migration to prep merge * re-add migration * cleanup code to use mcp sdk types * fix discovery calls * add migration * ui improvements * fix lint * fix types * fix lint * fix spacing * remove migration to prep merge * add migration back * fix imports * fix tool refresh ux * fix test failures * fix tests * cleanup code * styling improvements, ability to edit mcp server description, etc * fixed ui in light mode api keys modal * update docs * deprecated unused input components, shifted to emcn * updated playground, simplified components * move images and videos * updated more docs images --------- Co-authored-by: priyanshu.solanki <priyanshu.solanki@saviynt.com> Co-authored-by: Siddharth Ganesan <siddharthganesan@gmail.com> Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai> Co-authored-by: waleed <walif6@gmail.com>
…rs and mcp tools (#2415) * added a workflow as mcp * fixed the issue of UI rendering for deleted mcp servers * fixing lint issues * using mcn components * fixing merge conflicts * fix * fix lint errors * refactored code to use hasstartblock from the tirgger utils * removing unecessary auth * using official mcp sdk and added description fields * using normalised input schema function * ui fixes part 1 * remove migration before merge * fix merge conflicts * remove migration to prep merge * re-add migration * cleanup code to use mcp sdk types * fix discovery calls * add migration * ui improvements * fix lint * fix types * fix lint * fix spacing * remove migration to prep merge * add migration back * fix imports * fix tool refresh ux * fix test failures * fix tests * cleanup code * styling improvements, ability to edit mcp server description, etc * fixed ui in light mode api keys modal * update docs * deprecated unused input components, shifted to emcn * updated playground, simplified components * move images and videos * updated more docs images --------- Co-authored-by: priyanshu.solanki <priyanshu.solanki@saviynt.com> Co-authored-by: Siddharth Ganesan <siddharthganesan@gmail.com> Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai> Co-authored-by: waleed <walif6@gmail.com>
Summary
We wrap the existing API calls as MCP tool endpoints and use them to trigger workflows from MCP servers.
Type of Change
Testing
Tested manually with @Sg312
Checklist