codemie-mcp-workflows 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- codemie_mcp_workflows-0.2.0/PKG-INFO +172 -0
- codemie_mcp_workflows-0.2.0/README.md +149 -0
- codemie_mcp_workflows-0.2.0/pyproject.toml +42 -0
- codemie_mcp_workflows-0.2.0/src/codemie_mcp_workflows/__init__.py +15 -0
- codemie_mcp_workflows-0.2.0/src/codemie_mcp_workflows/model.py +146 -0
- codemie_mcp_workflows-0.2.0/src/codemie_mcp_workflows/server.py +109 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codemie-mcp-workflows
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: MCP server for connecting to CodeMie Workflows API
|
|
5
|
+
License: Apache-2.0
|
|
6
|
+
Author: EPAM Systems
|
|
7
|
+
Requires-Python: >=3.12,<4.0
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
14
|
+
Requires-Dist: certifi (>=2025.1.31)
|
|
15
|
+
Requires-Dist: codemie-sdk-python (>=0.1.620,<0.2)
|
|
16
|
+
Requires-Dist: httpx (>=0.27.0,<0.28.0)
|
|
17
|
+
Requires-Dist: mcp (>=1.6.0,<2.0.0)
|
|
18
|
+
Requires-Dist: pydantic (>=2.11.2,<3.0.0)
|
|
19
|
+
Project-URL: Homepage, https://github.com/codemie-ai/codemie-mcp-servers
|
|
20
|
+
Project-URL: Repository, https://github.com/codemie-ai/codemie-mcp-servers
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# CodeMie Workflows MCP Server
|
|
24
|
+
|
|
25
|
+
Python server implementing Model Context Protocol (MCP) for CodeMie Workflows operations.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
- Execute CodeMie workflows
|
|
29
|
+
- Manage workflow executions
|
|
30
|
+
- Integration with CodeMie Workflow API
|
|
31
|
+
|
|
32
|
+
Note: The server requires authentication credentials via environment variables.
|
|
33
|
+
|
|
34
|
+
## API
|
|
35
|
+
|
|
36
|
+
### Tools
|
|
37
|
+
|
|
38
|
+
#### execute
|
|
39
|
+
Execute a specific workflow
|
|
40
|
+
Inputs:
|
|
41
|
+
- `workflow_id (string)`: Workflow identifier to execute
|
|
42
|
+
- `parameters (object, optional)`: Workflow execution parameters
|
|
43
|
+
- `execution_id (string, optional)`: Custom execution identifier
|
|
44
|
+
|
|
45
|
+
Returns workflow execution details and status
|
|
46
|
+
|
|
47
|
+
## Breaking changes in 0.2.0
|
|
48
|
+
|
|
49
|
+
- The Python package is now `codemie_mcp_workflows`. The command `codemie-mcp-workflows` is unchanged.
|
|
50
|
+
- The server no longer has built-in server addresses. `CODEMIE_AUTH_SERVER_URL`, `CODEMIE_AUTH_REALM_NAME` and `CODEMIE_API_DOMAIN` are required. Without them the server exits with an error.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Ensure you have `Python 3.12` or later installed.
|
|
55
|
+
|
|
56
|
+
**Important:** Before running the MCP server, you must configure the required environment variables (see [Environment Variables](#environment-variables) section below).
|
|
57
|
+
|
|
58
|
+
### Using uv (recommended)
|
|
59
|
+
|
|
60
|
+
When using [`uv`](https://docs.astral.sh/uv/) no specific installation is needed. We will
|
|
61
|
+
use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *codemie-mcp-workflows*.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
uvx codemie-mcp-workflows
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Using pip
|
|
68
|
+
|
|
69
|
+
Alternatively you can install the package with pip:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install codemie-mcp-workflows
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
After installation, you can run it as a script using:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
codemie-mcp-workflows
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
### Configure for Claude.app
|
|
84
|
+
|
|
85
|
+
Add to your Claude settings:
|
|
86
|
+
|
|
87
|
+
<details>
|
|
88
|
+
<summary>Using uvx</summary>
|
|
89
|
+
|
|
90
|
+
**Required variables:**
|
|
91
|
+
```json
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"codemie-workflows": {
|
|
94
|
+
"command": "uvx",
|
|
95
|
+
"args": ["codemie-mcp-workflows"],
|
|
96
|
+
"env": {
|
|
97
|
+
"CODEMIE_AUTH_SERVER_URL": "https://auth.example.com/auth",
|
|
98
|
+
"CODEMIE_AUTH_REALM_NAME": "your-realm",
|
|
99
|
+
"CODEMIE_API_DOMAIN": "https://codemie.example.com/code-assistant-api",
|
|
100
|
+
"CODEMIE_USERNAME": "your-username",
|
|
101
|
+
"CODEMIE_PASSWORD": "your-password"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Optional variables:**
|
|
108
|
+
```json
|
|
109
|
+
"env": {
|
|
110
|
+
"CODEMIE_AUTH_CLIENT_ID": "codemie-sdk",
|
|
111
|
+
"CODEMIE_VERIFY_SSL": "true"
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
<details>
|
|
117
|
+
<summary>Using pip installation</summary>
|
|
118
|
+
|
|
119
|
+
**Required variables:**
|
|
120
|
+
```json
|
|
121
|
+
"mcpServers": {
|
|
122
|
+
"codemie-workflows": {
|
|
123
|
+
"command": "codemie-mcp-workflows",
|
|
124
|
+
"args": [],
|
|
125
|
+
"env": {
|
|
126
|
+
"CODEMIE_AUTH_SERVER_URL": "https://auth.example.com/auth",
|
|
127
|
+
"CODEMIE_AUTH_REALM_NAME": "your-realm",
|
|
128
|
+
"CODEMIE_API_DOMAIN": "https://codemie.example.com/code-assistant-api",
|
|
129
|
+
"CODEMIE_USERNAME": "your-username",
|
|
130
|
+
"CODEMIE_PASSWORD": "your-password"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Optional variables:**
|
|
137
|
+
```json
|
|
138
|
+
"env": {
|
|
139
|
+
"CODEMIE_AUTH_CLIENT_ID": "codemie-sdk",
|
|
140
|
+
"CODEMIE_VERIFY_SSL": "true"
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
</details>
|
|
144
|
+
|
|
145
|
+
### Environment Variables
|
|
146
|
+
|
|
147
|
+
#### Mandatory Variables
|
|
148
|
+
|
|
149
|
+
The following environment variables **must** be configured before running the MCP server:
|
|
150
|
+
|
|
151
|
+
**Platform settings (all three are required, an empty value counts as missing):**
|
|
152
|
+
- `CODEMIE_AUTH_SERVER_URL`: URL of your authentication server, for example `https://auth.example.com/auth`
|
|
153
|
+
- `CODEMIE_AUTH_REALM_NAME`: authentication realm name
|
|
154
|
+
- `CODEMIE_API_DOMAIN`: URL of your CodeMie API, for example `https://codemie.example.com/code-assistant-api`
|
|
155
|
+
|
|
156
|
+
The server has no built-in addresses. If any of the three is missing it prints `Missing required settings: <names>` and exits with a non-zero code, before any network call.
|
|
157
|
+
|
|
158
|
+
**Authentication (choose one method):**
|
|
159
|
+
|
|
160
|
+
*Option 1: Username/Password*
|
|
161
|
+
- `CODEMIE_USERNAME`: Your CodeMie username
|
|
162
|
+
- `CODEMIE_PASSWORD`: Your CodeMie password
|
|
163
|
+
|
|
164
|
+
*Option 2: Client Credentials*
|
|
165
|
+
- `CODEMIE_AUTH_CLIENT_SECRET`: Auth client secret
|
|
166
|
+
|
|
167
|
+
#### Optional Variables
|
|
168
|
+
|
|
169
|
+
- `CODEMIE_AUTH_CLIENT_ID`: authentication client ID (default: `codemie-sdk`)
|
|
170
|
+
|
|
171
|
+
- `CODEMIE_VERIFY_SSL`: TLS certificate verification flag (default: `true`). Set `false` only for local testing.
|
|
172
|
+
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# CodeMie Workflows MCP Server
|
|
2
|
+
|
|
3
|
+
Python server implementing Model Context Protocol (MCP) for CodeMie Workflows operations.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Execute CodeMie workflows
|
|
7
|
+
- Manage workflow executions
|
|
8
|
+
- Integration with CodeMie Workflow API
|
|
9
|
+
|
|
10
|
+
Note: The server requires authentication credentials via environment variables.
|
|
11
|
+
|
|
12
|
+
## API
|
|
13
|
+
|
|
14
|
+
### Tools
|
|
15
|
+
|
|
16
|
+
#### execute
|
|
17
|
+
Execute a specific workflow
|
|
18
|
+
Inputs:
|
|
19
|
+
- `workflow_id (string)`: Workflow identifier to execute
|
|
20
|
+
- `parameters (object, optional)`: Workflow execution parameters
|
|
21
|
+
- `execution_id (string, optional)`: Custom execution identifier
|
|
22
|
+
|
|
23
|
+
Returns workflow execution details and status
|
|
24
|
+
|
|
25
|
+
## Breaking changes in 0.2.0
|
|
26
|
+
|
|
27
|
+
- The Python package is now `codemie_mcp_workflows`. The command `codemie-mcp-workflows` is unchanged.
|
|
28
|
+
- The server no longer has built-in server addresses. `CODEMIE_AUTH_SERVER_URL`, `CODEMIE_AUTH_REALM_NAME` and `CODEMIE_API_DOMAIN` are required. Without them the server exits with an error.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
Ensure you have `Python 3.12` or later installed.
|
|
33
|
+
|
|
34
|
+
**Important:** Before running the MCP server, you must configure the required environment variables (see [Environment Variables](#environment-variables) section below).
|
|
35
|
+
|
|
36
|
+
### Using uv (recommended)
|
|
37
|
+
|
|
38
|
+
When using [`uv`](https://docs.astral.sh/uv/) no specific installation is needed. We will
|
|
39
|
+
use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *codemie-mcp-workflows*.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
uvx codemie-mcp-workflows
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Using pip
|
|
46
|
+
|
|
47
|
+
Alternatively you can install the package with pip:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install codemie-mcp-workflows
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
After installation, you can run it as a script using:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
codemie-mcp-workflows
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
### Configure for Claude.app
|
|
62
|
+
|
|
63
|
+
Add to your Claude settings:
|
|
64
|
+
|
|
65
|
+
<details>
|
|
66
|
+
<summary>Using uvx</summary>
|
|
67
|
+
|
|
68
|
+
**Required variables:**
|
|
69
|
+
```json
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"codemie-workflows": {
|
|
72
|
+
"command": "uvx",
|
|
73
|
+
"args": ["codemie-mcp-workflows"],
|
|
74
|
+
"env": {
|
|
75
|
+
"CODEMIE_AUTH_SERVER_URL": "https://auth.example.com/auth",
|
|
76
|
+
"CODEMIE_AUTH_REALM_NAME": "your-realm",
|
|
77
|
+
"CODEMIE_API_DOMAIN": "https://codemie.example.com/code-assistant-api",
|
|
78
|
+
"CODEMIE_USERNAME": "your-username",
|
|
79
|
+
"CODEMIE_PASSWORD": "your-password"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Optional variables:**
|
|
86
|
+
```json
|
|
87
|
+
"env": {
|
|
88
|
+
"CODEMIE_AUTH_CLIENT_ID": "codemie-sdk",
|
|
89
|
+
"CODEMIE_VERIFY_SSL": "true"
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
</details>
|
|
93
|
+
|
|
94
|
+
<details>
|
|
95
|
+
<summary>Using pip installation</summary>
|
|
96
|
+
|
|
97
|
+
**Required variables:**
|
|
98
|
+
```json
|
|
99
|
+
"mcpServers": {
|
|
100
|
+
"codemie-workflows": {
|
|
101
|
+
"command": "codemie-mcp-workflows",
|
|
102
|
+
"args": [],
|
|
103
|
+
"env": {
|
|
104
|
+
"CODEMIE_AUTH_SERVER_URL": "https://auth.example.com/auth",
|
|
105
|
+
"CODEMIE_AUTH_REALM_NAME": "your-realm",
|
|
106
|
+
"CODEMIE_API_DOMAIN": "https://codemie.example.com/code-assistant-api",
|
|
107
|
+
"CODEMIE_USERNAME": "your-username",
|
|
108
|
+
"CODEMIE_PASSWORD": "your-password"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Optional variables:**
|
|
115
|
+
```json
|
|
116
|
+
"env": {
|
|
117
|
+
"CODEMIE_AUTH_CLIENT_ID": "codemie-sdk",
|
|
118
|
+
"CODEMIE_VERIFY_SSL": "true"
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
</details>
|
|
122
|
+
|
|
123
|
+
### Environment Variables
|
|
124
|
+
|
|
125
|
+
#### Mandatory Variables
|
|
126
|
+
|
|
127
|
+
The following environment variables **must** be configured before running the MCP server:
|
|
128
|
+
|
|
129
|
+
**Platform settings (all three are required, an empty value counts as missing):**
|
|
130
|
+
- `CODEMIE_AUTH_SERVER_URL`: URL of your authentication server, for example `https://auth.example.com/auth`
|
|
131
|
+
- `CODEMIE_AUTH_REALM_NAME`: authentication realm name
|
|
132
|
+
- `CODEMIE_API_DOMAIN`: URL of your CodeMie API, for example `https://codemie.example.com/code-assistant-api`
|
|
133
|
+
|
|
134
|
+
The server has no built-in addresses. If any of the three is missing it prints `Missing required settings: <names>` and exits with a non-zero code, before any network call.
|
|
135
|
+
|
|
136
|
+
**Authentication (choose one method):**
|
|
137
|
+
|
|
138
|
+
*Option 1: Username/Password*
|
|
139
|
+
- `CODEMIE_USERNAME`: Your CodeMie username
|
|
140
|
+
- `CODEMIE_PASSWORD`: Your CodeMie password
|
|
141
|
+
|
|
142
|
+
*Option 2: Client Credentials*
|
|
143
|
+
- `CODEMIE_AUTH_CLIENT_SECRET`: Auth client secret
|
|
144
|
+
|
|
145
|
+
#### Optional Variables
|
|
146
|
+
|
|
147
|
+
- `CODEMIE_AUTH_CLIENT_ID`: authentication client ID (default: `codemie-sdk`)
|
|
148
|
+
|
|
149
|
+
- `CODEMIE_VERIFY_SSL`: TLS certificate verification flag (default: `true`). Set `false` only for local testing.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "codemie-mcp-workflows"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "MCP server for connecting to CodeMie Workflows API"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
packages = [
|
|
7
|
+
{ include = "codemie_mcp_workflows", from = "src" }
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
[tool.poetry]
|
|
11
|
+
name = "codemie-mcp-workflows"
|
|
12
|
+
version = "0.2.0"
|
|
13
|
+
description = "MCP server for connecting to CodeMie Workflows API"
|
|
14
|
+
authors = ["EPAM Systems"]
|
|
15
|
+
license = "Apache-2.0"
|
|
16
|
+
homepage = "https://github.com/codemie-ai/codemie-mcp-servers"
|
|
17
|
+
repository = "https://github.com/codemie-ai/codemie-mcp-servers"
|
|
18
|
+
readme = "README.md"
|
|
19
|
+
packages = [
|
|
20
|
+
{ include = "codemie_mcp_workflows", from = "src" }
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[tool.poetry.dependencies]
|
|
24
|
+
python = "^3.12"
|
|
25
|
+
mcp = "^1.6.0"
|
|
26
|
+
httpx = "^0.27.0"
|
|
27
|
+
codemie-sdk-python = ">=0.1.620,<0.2"
|
|
28
|
+
certifi = ">=2025.1.31"
|
|
29
|
+
pydantic = "^2.11.2"
|
|
30
|
+
|
|
31
|
+
[tool.poetry.group.dev.dependencies]
|
|
32
|
+
pytest = "^8.0.0"
|
|
33
|
+
black = "^24.1.0"
|
|
34
|
+
isort = "^5.13.2"
|
|
35
|
+
ruff = "^0.11.3"
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["poetry-core"]
|
|
39
|
+
build-backend = "poetry.core.masonry.api"
|
|
40
|
+
|
|
41
|
+
[tool.poetry.scripts]
|
|
42
|
+
codemie-mcp-workflows = "codemie_mcp_workflows.server:main"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""Workflow execution MCP implementation."""
|
|
2
|
+
|
|
3
|
+
from .model import (
|
|
4
|
+
WorkflowExecutionStatus,
|
|
5
|
+
WorkflowExecutionRequest,
|
|
6
|
+
WorkflowExecutionResponse,
|
|
7
|
+
)
|
|
8
|
+
from .server import execute_workflow
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
'WorkflowExecutionStatus',
|
|
12
|
+
'WorkflowExecutionRequest',
|
|
13
|
+
'WorkflowExecutionResponse',
|
|
14
|
+
'execute_workflow',
|
|
15
|
+
]
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Workflow execution models."""
|
|
2
|
+
import os
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from enum import Enum
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, Field, model_validator
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class WorkflowAuthConfig(BaseModel):
|
|
11
|
+
"""Authentication configuration with support for multiple auth methods."""
|
|
12
|
+
username: Optional[str] = Field(
|
|
13
|
+
default=None,
|
|
14
|
+
description="Username for password-based authentication"
|
|
15
|
+
)
|
|
16
|
+
password: Optional[str] = Field(
|
|
17
|
+
default=None,
|
|
18
|
+
description="Password for password-based authentication"
|
|
19
|
+
)
|
|
20
|
+
client_id: str = Field(
|
|
21
|
+
default="codemie-sdk",
|
|
22
|
+
description="Client ID for authentication"
|
|
23
|
+
)
|
|
24
|
+
client_secret: Optional[str] = Field(
|
|
25
|
+
default=None,
|
|
26
|
+
description="Client secret for client credentials"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
@model_validator(mode="after")
|
|
30
|
+
def validate_auth_method(self) -> "WorkflowAuthConfig":
|
|
31
|
+
"""Validates that either username/password or client credentials are provided."""
|
|
32
|
+
has_user_pass = bool(self.username and self.password)
|
|
33
|
+
has_client_creds = bool(self.client_id and self.client_secret)
|
|
34
|
+
|
|
35
|
+
if not (has_user_pass or has_client_creds):
|
|
36
|
+
raise ValueError(
|
|
37
|
+
"Authentication configuration missing. Please provide either:\n"
|
|
38
|
+
"- CODEMIE_USERNAME and CODEMIE_PASSWORD for password authentication\n"
|
|
39
|
+
"- CODEMIE_AUTH_CLIENT_ID and CODEMIE_AUTH_CLIENT_SECRET for client credentials"
|
|
40
|
+
)
|
|
41
|
+
return self
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
REQUIRED_SETTINGS = (
|
|
45
|
+
"CODEMIE_AUTH_SERVER_URL",
|
|
46
|
+
"CODEMIE_AUTH_REALM_NAME",
|
|
47
|
+
"CODEMIE_API_DOMAIN",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
_TRUE_VALUES = ("", "true", "1", "yes", "on")
|
|
51
|
+
_FALSE_VALUES = ("false", "0", "no", "off")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _read_required_settings() -> dict:
|
|
55
|
+
"""Returns the required settings; raises one ValueError naming every missing one."""
|
|
56
|
+
values = {name: os.environ.get(name, "").strip() for name in REQUIRED_SETTINGS}
|
|
57
|
+
missing = [name for name, value in values.items() if not value]
|
|
58
|
+
if missing:
|
|
59
|
+
raise ValueError("Missing required settings: " + ", ".join(missing))
|
|
60
|
+
return values
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _read_verify_ssl() -> bool:
|
|
64
|
+
"""Parses CODEMIE_VERIFY_SSL strictly; TLS verification stays on unless disabled explicitly."""
|
|
65
|
+
value = os.environ.get("CODEMIE_VERIFY_SSL", "").strip().lower()
|
|
66
|
+
if value in _TRUE_VALUES:
|
|
67
|
+
return True
|
|
68
|
+
if value in _FALSE_VALUES:
|
|
69
|
+
return False
|
|
70
|
+
raise ValueError(
|
|
71
|
+
"Invalid value for CODEMIE_VERIFY_SSL: use true or false"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class WorkflowSettings:
|
|
76
|
+
"""Application settings configured via environment variables."""
|
|
77
|
+
# Default values as class variables
|
|
78
|
+
DEFAULT_AUTH_CLIENT_ID = "codemie-sdk"
|
|
79
|
+
|
|
80
|
+
auth: WorkflowAuthConfig
|
|
81
|
+
api_domain: str
|
|
82
|
+
auth_realm_name: str
|
|
83
|
+
auth_server_url: str
|
|
84
|
+
verify_ssl: bool = True
|
|
85
|
+
|
|
86
|
+
def __init__(self):
|
|
87
|
+
required = _read_required_settings()
|
|
88
|
+
# Authentication settings
|
|
89
|
+
self.auth = WorkflowAuthConfig(
|
|
90
|
+
username=os.environ.get("CODEMIE_USERNAME"),
|
|
91
|
+
password=os.environ.get("CODEMIE_PASSWORD"),
|
|
92
|
+
client_id=os.environ.get(
|
|
93
|
+
"CODEMIE_AUTH_CLIENT_ID", self.DEFAULT_AUTH_CLIENT_ID
|
|
94
|
+
),
|
|
95
|
+
client_secret=os.environ.get("CODEMIE_AUTH_CLIENT_SECRET"),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Server configuration
|
|
99
|
+
self.auth_client_id = os.environ.get(
|
|
100
|
+
"CODEMIE_AUTH_CLIENT_ID", self.DEFAULT_AUTH_CLIENT_ID
|
|
101
|
+
)
|
|
102
|
+
self.auth_realm_name = required["CODEMIE_AUTH_REALM_NAME"]
|
|
103
|
+
self.auth_server_url = required["CODEMIE_AUTH_SERVER_URL"]
|
|
104
|
+
self.api_domain = required["CODEMIE_API_DOMAIN"]
|
|
105
|
+
self.verify_ssl = _read_verify_ssl()
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class WorkflowExecutionStatus(str, Enum):
|
|
109
|
+
"""Status of workflow execution"""
|
|
110
|
+
NOT_STARTED = "Not Started"
|
|
111
|
+
IN_PROGRESS = "In Progress"
|
|
112
|
+
SUCCEEDED = "Succeeded"
|
|
113
|
+
FAILED = "Failed"
|
|
114
|
+
INTERRUPTED = "Interrupted"
|
|
115
|
+
ABORTED = "Aborted"
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class WorkflowExecutionResponse(BaseModel):
|
|
119
|
+
"""Response model for workflow execution"""
|
|
120
|
+
id: str = Field(..., description="Unique identifier of the workflow")
|
|
121
|
+
execution_id: str = Field(..., description="Unique identifier of the execution")
|
|
122
|
+
workflow_id: str = Field(..., description="ID of the executed workflow")
|
|
123
|
+
status: WorkflowExecutionStatus = Field(
|
|
124
|
+
...,
|
|
125
|
+
alias="overall_status",
|
|
126
|
+
description="Current execution status"
|
|
127
|
+
)
|
|
128
|
+
created_date: datetime = Field(
|
|
129
|
+
...,
|
|
130
|
+
alias="date",
|
|
131
|
+
description="Execution creation timestamp"
|
|
132
|
+
)
|
|
133
|
+
prompt: str = Field(..., description="User input/prompt for the execution")
|
|
134
|
+
updated_date: Optional[datetime] = Field(None, description="Last update timestamp")
|
|
135
|
+
|
|
136
|
+
class Config:
|
|
137
|
+
populate_by_name = True
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class WorkflowExecutionRequest(BaseModel):
|
|
141
|
+
"""Request model for workflow execution"""
|
|
142
|
+
workflow_id: str = Field(..., description="ID of the workflow to execute")
|
|
143
|
+
user_input: str = Field(
|
|
144
|
+
default="",
|
|
145
|
+
description="Optional user input/prompt for the workflow"
|
|
146
|
+
)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Workflow execution MCP server implementation."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Dict, Any
|
|
5
|
+
|
|
6
|
+
from mcp.server.fastmcp import FastMCP
|
|
7
|
+
|
|
8
|
+
from codemie_sdk import CodeMieClient
|
|
9
|
+
from .model import (
|
|
10
|
+
WorkflowExecutionRequest,
|
|
11
|
+
WorkflowExecutionResponse,
|
|
12
|
+
WorkflowSettings
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Initialize settings at module level
|
|
16
|
+
try:
|
|
17
|
+
settings = WorkflowSettings()
|
|
18
|
+
except Exception as e:
|
|
19
|
+
print(f"Error initializing settings: {str(e)}", file=sys.stderr)
|
|
20
|
+
sys.exit(1)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def get_client() -> CodeMieClient:
|
|
24
|
+
"""Gets authenticated CodeMie client instance."""
|
|
25
|
+
try:
|
|
26
|
+
client = CodeMieClient(
|
|
27
|
+
username=settings.auth.username,
|
|
28
|
+
password=settings.auth.password,
|
|
29
|
+
auth_client_id=settings.auth.client_id,
|
|
30
|
+
auth_client_secret=settings.auth.client_secret,
|
|
31
|
+
verify_ssl=settings.verify_ssl,
|
|
32
|
+
auth_realm_name=settings.auth_realm_name,
|
|
33
|
+
auth_server_url=settings.auth_server_url,
|
|
34
|
+
codemie_api_domain=settings.api_domain,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
if not client.token:
|
|
38
|
+
print("Failed to obtain authentication token", file=sys.stderr)
|
|
39
|
+
raise ValueError("Failed to obtain authentication token")
|
|
40
|
+
|
|
41
|
+
print("Successfully initialized CodeMie client", file=sys.stderr)
|
|
42
|
+
return client
|
|
43
|
+
except Exception as e:
|
|
44
|
+
print(f"Error initializing client: {str(e)}", file=sys.stderr)
|
|
45
|
+
raise
|
|
46
|
+
|
|
47
|
+
# Initialize FastMCP server
|
|
48
|
+
mcp = FastMCP("codemie-workflows")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@mcp.tool()
|
|
52
|
+
async def execute_workflow(workflow_id: str, user_input: str = "") -> Dict[str, Any]:
|
|
53
|
+
"""
|
|
54
|
+
Execute a workflow with the given ID and optional user input.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
workflow_id: ID of the workflow to execute
|
|
58
|
+
user_input: Optional user input/prompt for the workflow
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
Dictionary containing execution details including:
|
|
62
|
+
- id: Workflow identifier
|
|
63
|
+
- execution_id: Unique identifier for this execution
|
|
64
|
+
- workflow_id: Source workflow ID
|
|
65
|
+
- status: Current execution status
|
|
66
|
+
- date: Creation timestamp
|
|
67
|
+
- prompt: User input that triggered the execution
|
|
68
|
+
- updated_date: Last update timestamp (if available)
|
|
69
|
+
|
|
70
|
+
Raises:
|
|
71
|
+
ValueError: If workflow_id is invalid or missing
|
|
72
|
+
Exception: For other execution errors
|
|
73
|
+
"""
|
|
74
|
+
try:
|
|
75
|
+
# Input validation
|
|
76
|
+
request = WorkflowExecutionRequest(
|
|
77
|
+
workflow_id=workflow_id,
|
|
78
|
+
user_input=user_input
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
# Get client and execute workflow
|
|
82
|
+
client = get_client()
|
|
83
|
+
response = client.workflows.run(
|
|
84
|
+
workflow_id=request.workflow_id,
|
|
85
|
+
user_input=request.user_input
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Validate and return response
|
|
89
|
+
execution_response = WorkflowExecutionResponse.model_validate(response)
|
|
90
|
+
return execution_response.model_dump(exclude_none=True)
|
|
91
|
+
|
|
92
|
+
except ValueError as ve:
|
|
93
|
+
print(f"Validation error: {str(ve)}", file=sys.stderr)
|
|
94
|
+
raise
|
|
95
|
+
except Exception as e:
|
|
96
|
+
print(f"Error executing workflow {workflow_id}: {str(e)}", file=sys.stderr)
|
|
97
|
+
raise
|
|
98
|
+
|
|
99
|
+
def main():
|
|
100
|
+
try:
|
|
101
|
+
print("Starting CodeMie Workflows MCP server", file=sys.stderr)
|
|
102
|
+
# Initialize and run the server
|
|
103
|
+
mcp.run(transport="stdio")
|
|
104
|
+
except Exception as e:
|
|
105
|
+
print(f"Error starting MCP server: {str(e)}", file=sys.stderr)
|
|
106
|
+
sys.exit(1)
|
|
107
|
+
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
main()
|