-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(workflow-as-mcp): wrapping workflows in the same workspace as MCP tools to particular MCP servers #2415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR adds MCP (Model Context Protocol) integration allowing workflows to be exposed as tools to external MCP clients. The implementation wraps existing workflow execution APIs as MCP-compliant JSON-RPC endpoints. Key Changes:
Issues Found:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as MCP Client
participant Serve as MCP Serve Route
participant DB as Database
participant WorkflowAPI as Workflow Execute API
participant Executor as Workflow Executor
Note over Client,Executor: MCP Tool Call Flow
Client->>Serve: POST tools/call request
Serve->>DB: Query workflow_mcp_tool table
DB-->>Serve: Tool metadata
Serve->>DB: Check workflow deployment
DB-->>Serve: isDeployed status
alt Not deployed
Serve-->>Client: Error: Not deployed
end
Serve->>WorkflowAPI: Fetch execute endpoint
WorkflowAPI->>Executor: Run workflow blocks
Executor-->>WorkflowAPI: Result
WorkflowAPI-->>Serve: Execution output
Serve-->>Client: CallToolResult
Note over Client,Executor: Tool Registration
Client->>Serve: POST tools/list request
Serve->>DB: Query tool schemas
DB-->>Serve: Tools with parameters
Serve-->>Client: ListToolsResult
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
29 files reviewed, 4 comments
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
31 files reviewed, 5 comments
.../components/panel/components/deploy/components/deploy-modal/components/mcp-tool/mcp-tool.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
41 files reviewed, 4 comments
| for (const field of inputFormat) { | ||
| if (!field.name) continue | ||
|
|
||
| const zodType = fieldTypeToZod(field.type, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: hardcoded true for isRequired - all Zod schemas created will be required even if workflow parameters should be optional
Consider passing field.required or a similar flag if available from InputFormatField
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/lib/mcp/workflow-tool-schema.ts
Line: 84:84
Comment:
**style:** hardcoded `true` for `isRequired` - all Zod schemas created will be required even if workflow parameters should be optional
Consider passing `field.required` or a similar flag if available from `InputFormatField`
How can I resolve this? If you propose a fix, please make it concise.| useEffect(() => { | ||
| if (!hasLoadedInitialData.current) return | ||
| if (!toolName.trim()) return | ||
|
|
||
| const toolsToUpdate: Array<{ serverId: string; toolId: string }> = [] | ||
| for (const server of servers) { | ||
| const toolInfo = serverToolsMap[server.id] | ||
| if (toolInfo?.tool) { | ||
| toolsToUpdate.push({ serverId: server.id, toolId: toolInfo.tool.id }) | ||
| } | ||
| } | ||
|
|
||
| if (toolsToUpdate.length === 0) return | ||
|
|
||
| const timeoutId = setTimeout(async () => { | ||
| for (const { serverId, toolId } of toolsToUpdate) { | ||
| try { | ||
| await updateToolMutation.mutateAsync({ | ||
| workspaceId, | ||
| serverId, | ||
| toolId, | ||
| toolName: toolName.trim(), | ||
| toolDescription: toolDescription.trim() || undefined, | ||
| parameterSchema, | ||
| }) | ||
| } catch (error) { | ||
| logger.error(`Failed to sync tool ${toolId}:`, error) | ||
| } | ||
| } | ||
| }, 500) | ||
|
|
||
| return () => clearTimeout(timeoutId) | ||
| }, [ | ||
| toolName, | ||
| toolDescription, | ||
| parameterSchema, | ||
| servers, | ||
| serverToolsMap, | ||
| workspaceId, | ||
| updateToolMutation, | ||
| ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: auto-sync logic updates all deployed tools whenever any field changes - could cause race conditions if user rapidly edits fields, or conflicts if multiple users edit the same workflow
Consider adding optimistic locking or version tracking
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/mcp-tool/mcp-tool.tsx
Line: 206:246
Comment:
**style:** auto-sync logic updates all deployed tools whenever any field changes - could cause race conditions if user rapidly edits fields, or conflicts if multiple users edit the same workflow
Consider adding optimistic locking or version tracking
How can I resolve this? If you propose a fix, please make it concise.
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