MCP Workflow Server
Orchestrates multiple MCP tool calls into sequential workflows with conditional logic, data transformation via JSONPath, and workflow templates.
README
MCP Workflow Server
A powerful orchestration server for the Model Context Protocol (MCP) that enables chaining multiple MCP tool calls into unified workflows.
Overview
MCP Workflow Server allows you to:
- Chain multiple MCP tool calls into sequential workflows
- Save and reuse workflows as templates for common tasks
- Use JSONPath expressions to pass data between workflow steps
- Support conditional execution with if/else logic
- Manage multiple MCP servers from a single orchestration point
Features
- 🔗 Workflow Orchestration: Chain multiple MCP tool calls with data flow between steps
- 📦 Workflow Templates: Save and reuse common workflow patterns
- 🔀 Data Transformation: Use JSONPath expressions to extract and transform data between steps
- ⚡ Conditional Logic: Execute steps conditionally based on previous results
- 🌐 Multiple Transports: Support for both stdio and SSE (Server-Sent Events) transports
- 🔄 Hot Reload: Automatic configuration reloading when config files change
- 📊 Comprehensive Logging: Detailed execution logs for debugging
Installation
npm install
npm run build
Quick Start
1. Configure MCP Servers
Create a config.json file (use config.example.json as a template):
{
"mcpServers": {
"gitlab": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-gitlab"],
"env": {
"GITLAB_PERSONAL_ACCESS_TOKEN": "your-token",
"GITLAB_API_URL": "https://gitlab.com/api/v4"
}
},
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
},
"crawl4ai": {
"type": "sse",
"url": "http://localhost:11235/mcp/sse"
}
}
}
2. Start the Server
Stdio Mode (default):
npm start
SSE Mode:
npm run start:sse
# or
TRANSPORT_TYPE=sse PORT=3001 npm start
Custom Workflows Path:
# Use custom workflows file
npm start -- --workflows ./custom-workflows.json
# Or with full options
node dist/main.js --config ./config.json --workflows ./my-workflows.json --transport sse --port 3001
3. Use the Workflow Tools
The server provides three main tools:
get_workflows
Lists all available workflow templates:
{
"tool": "get_workflows",
"arguments": {}
}
execute_workflow
Executes a workflow with initial inputs:
{
"tool": "execute_workflow",
"arguments": {
"workflow_spec": {
"description": "Search GitLab and open first result",
"steps": [
{
"server_name": "gitlab",
"tool_name": "search_repositories",
"outputs": {
"url": "$.items[0].web_url"
}
},
{
"server_name": "playwright",
"tool_name": "browser_navigate",
"inputs": {
"url": "$.url"
}
}
]
},
"initial_workflow_inputs": {
"search": "react"
}
}
}
add_workflow
Saves a new workflow template:
{
"tool": "add_workflow",
"arguments": {
"name": "search_and_browse",
"workflow_spec": {
"description": "Search GitLab repositories and open the first result in browser",
"steps": [...]
}
}
}
Workflow Specification
Basic Structure
{
"description": "Clear description of what the workflow does",
"steps": [
{
"server_name": "target_mcp_server",
"tool_name": "tool_to_call",
"if": "optional_condition",
"inputs": {
"param1": "$.path.to.data",
"param2": "static_value"
},
"outputs": {
"variable_name": "$.result.path"
}
}
]
}
Step Properties
server_name(required): Name of the MCP server to calltool_name(required): Name of the tool to invokeif(optional): Boolean condition for conditional executioninputs(optional): Input parameters with JSONPath expressions or static valuesoutputs(optional): Output mappings using JSONPath expressions
JSONPath Examples
Extract data from previous step results:
{
"inputs": {
"url": "$.items[0].web_url", // First item's URL
"names": "$.users[*].name", // All user names
"count": "$.items.length", // Array length
"first_user": "$.users[0]" // First user object
}
}
Conditional Execution
{
"server_name": "some_server",
"tool_name": "conditional_tool",
"if": "items.length > 0",
"inputs": {
"data": "$.items[0]"
}
}
Example Workflows
1. Search and Browse Workflow
{
"search_and_browse": {
"description": "Search GitLab repositories and open the first result in browser",
"steps": [
{
"server_name": "gitlab",
"tool_name": "search_repositories",
"outputs": {
"url": "$.items[0].web_url",
"name": "$.items[0].name"
}
},
{
"server_name": "playwright",
"tool_name": "browser_navigate",
"inputs": {
"url": "$.url"
}
}
]
}
}
2. Web Scraping and Analysis
{
"scrape_and_analyze": {
"description": "Scrape a webpage and analyze its content",
"steps": [
{
"server_name": "crawl4ai",
"tool_name": "md",
"outputs": {
"content": "$.markdown"
}
},
{
"server_name": "analysis_server",
"tool_name": "analyze_text",
"inputs": {
"text": "$.content"
}
}
]
}
}
Configuration
Server Configuration
{
"mcpServers": {
"server_name": {
"command": "path/to/executable",
"args": ["arg1", "arg2"],
"type": "stdio",
"env": {
"ENV_VAR": "value"
},
"disabled": false
}
}
}
Workflows Configuration
By default, workflows are stored in workflows.json in the current working directory. You can specify a custom path using the --workflows option:
# Use custom workflows file
node dist/main.js --workflows /path/to/my-workflows.json
# Relative path
node dist/main.js --workflows ./config/workflows.json
The workflows file structure remains the same regardless of location:
{
"workflow_name": {
"description": "Description of what the workflow does",
"steps": [
{
"server_name": "server_name",
"tool_name": "tool_name",
"inputs": { "param": "value" },
"outputs": { "result": "$.path" }
}
]
}
}
Transport Types
stdio: Standard input/output communicationsse: Server-Sent Events over HTTPstreamhttp: HTTP streaming
Configuration Options
command: Executable path (for stdio)args: Command line argumentstype: Transport type (stdio,sse,streamhttp)url: Server URL (for sse/streamhttp)env: Environment variablesdisabled: Skip server initialization
Command Line Options
node dist/main.js [options]
Options:
-c, --config Path to configuration file (default: config.json)
-j, --jsonpath JSONPath expression to select config section
-w, --workflows Path to workflows JSON file (default: workflows.json)
-t, --transport Transport type: stdio, sse (default: stdio)
-p, --port Port for SSE transport (default: 3001)
-h, --help Show help
Development
Project Structure
src/
├── main.ts # CLI entry point
├── server.ts # MCP server implementation
├── types.ts # TypeScript type definitions
├── configLoader.ts # Configuration loading and watching
├── mcpClient.ts # MCP client management
├── workflowExecutor.ts # Workflow execution engine
├── workflowLoader.ts # Workflow template loading
└── workflowManager.ts # Workflow CRUD operations
Development Scripts
npm run dev # Run in development mode with hot reload
npm run watch # Watch mode with automatic restart
npm run build # Build TypeScript to JavaScript
npm start # Start production server
Adding New Features
- Extend Types: Add new interfaces in
src/types.ts - Update Server: Register new tools in
src/server.ts - Implement Logic: Add business logic in appropriate modules
- Test: Create test workflows in
workflows.json
Troubleshooting
Common Issues
- Server not found: Check
config.jsonserver configuration - Tool call failed: Verify tool name and arguments
- JSONPath errors: Validate JSONPath expressions
- Permission denied: Check file permissions and environment variables
Debug Mode
Enable detailed logging:
DEBUG=* npm start
Configuration Validation
The server validates:
- Workflow structure and required fields
- Server availability and tool existence
- JSONPath expression syntax
- Conditional logic expressions
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- Check the troubleshooting section
- Review example configurations
- Open an issue on GitHub
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。