awslabs.stepfunctions-tool-mcp-server 0.1.4__py3-none-any.whl

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.
awslabs/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ # This file is part of the awslabs namespace.
2
+ # It is intentionally minimal to support PEP 420 namespace packages.
@@ -0,0 +1,3 @@
1
+ """awslabs.stepfunctions-tool-mcp-server"""
2
+
3
+ __version__ = '0.0.0'
@@ -0,0 +1,402 @@
1
+ """awslabs Step Functions Tool MCP Server implementation."""
2
+
3
+ import asyncio
4
+ import boto3
5
+ import json
6
+ import logging
7
+ import os
8
+ import re
9
+ from mcp.server.fastmcp import Context, FastMCP
10
+ from typing import Optional
11
+
12
+
13
+ # Set up logging
14
+ logging.basicConfig(level=logging.INFO)
15
+ logger = logging.getLogger(__name__)
16
+
17
+ AWS_PROFILE = os.environ.get('AWS_PROFILE', 'default')
18
+ logger.info(f'AWS_PROFILE: {AWS_PROFILE}')
19
+
20
+ AWS_REGION = os.environ.get('AWS_REGION', 'us-east-1')
21
+ logger.info(f'AWS_REGION: {AWS_REGION}')
22
+
23
+ STATE_MACHINE_PREFIX = os.environ.get('STATE_MACHINE_PREFIX', '')
24
+ logger.info(f'STATE_MACHINE_PREFIX: {STATE_MACHINE_PREFIX}')
25
+
26
+ STATE_MACHINE_LIST = [
27
+ state_machine_name.strip()
28
+ for state_machine_name in os.environ.get('STATE_MACHINE_LIST', '').split(',')
29
+ if state_machine_name.strip()
30
+ ]
31
+ logger.info(f'STATE_MACHINE_LIST: {STATE_MACHINE_LIST}')
32
+
33
+ STATE_MACHINE_TAG_KEY = os.environ.get('STATE_MACHINE_TAG_KEY', '')
34
+ logger.info(f'STATE_MACHINE_TAG_KEY: {STATE_MACHINE_TAG_KEY}')
35
+
36
+ STATE_MACHINE_TAG_VALUE = os.environ.get('STATE_MACHINE_TAG_VALUE', '')
37
+ logger.info(f'STATE_MACHINE_TAG_VALUE: {STATE_MACHINE_TAG_VALUE}')
38
+
39
+ STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY = os.environ.get('STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY')
40
+ logger.info(f'STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY: {STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY}')
41
+
42
+ # Initialize AWS clients
43
+ session = boto3.Session(profile_name=AWS_PROFILE, region_name=AWS_REGION)
44
+ sfn_client = session.client('stepfunctions')
45
+ schemas_client = session.client('schemas')
46
+
47
+ mcp = FastMCP(
48
+ 'awslabs.stepfunctions-tool-mcp-server',
49
+ instructions="""Use AWS Step Functions state machines to improve your answers.
50
+ These state machines give you additional capabilities and access to AWS services and resources in an AWS account.""",
51
+ dependencies=['pydantic', 'boto3'],
52
+ )
53
+
54
+
55
+ def validate_state_machine_name(state_machine_name: str) -> bool:
56
+ """Validate that the state machine name is valid and can be called."""
57
+ # If both prefix and list are empty, consider all state machines valid
58
+ if not STATE_MACHINE_PREFIX and not STATE_MACHINE_LIST:
59
+ return True
60
+
61
+ # Otherwise, check if the state machine name matches the prefix or is in the list
62
+ return (STATE_MACHINE_PREFIX and state_machine_name.startswith(STATE_MACHINE_PREFIX)) or (
63
+ state_machine_name in STATE_MACHINE_LIST
64
+ )
65
+
66
+
67
+ def sanitize_tool_name(name: str) -> str:
68
+ """Sanitize a Step Functions state machine name to be used as a tool name."""
69
+ # Remove prefix if present
70
+ if name.startswith(STATE_MACHINE_PREFIX):
71
+ name = name[len(STATE_MACHINE_PREFIX) :]
72
+
73
+ # Replace invalid characters with underscore
74
+ name = re.sub(r'[^a-zA-Z0-9_]', '_', name)
75
+
76
+ # Ensure name doesn't start with a number
77
+ if name and name[0].isdigit():
78
+ name = '_' + name
79
+
80
+ return name
81
+
82
+
83
+ def format_state_machine_response(state_machine_name: str, payload: bytes) -> str:
84
+ """Format the Step Functions state machine response payload."""
85
+ try:
86
+ # Try to parse the payload as JSON
87
+ payload_json = json.loads(payload)
88
+ return f'State machine {state_machine_name} returned: {json.dumps(payload_json, indent=2)}'
89
+ except (json.JSONDecodeError, UnicodeDecodeError):
90
+ # Return raw payload if not JSON
91
+ return f'State machine {state_machine_name} returned payload: {payload}'
92
+
93
+
94
+ async def invoke_standard_state_machine_impl(
95
+ state_machine_name: str, state_machine_arn: str, parameters: dict, ctx: Context
96
+ ) -> str:
97
+ """Execute a Standard state machine using StartExecution and poll for completion."""
98
+ await ctx.info(
99
+ f'Starting asynchronous execution of Standard state machine {state_machine_name}'
100
+ )
101
+
102
+ # Start the execution
103
+ response = sfn_client.start_execution(
104
+ stateMachineArn=state_machine_arn,
105
+ input=json.dumps(parameters),
106
+ )
107
+
108
+ await ctx.info(f'Started execution {response["executionArn"]}')
109
+
110
+ # Wait for execution to complete
111
+ while True:
112
+ execution = sfn_client.describe_execution(executionArn=response['executionArn'])
113
+ status = execution['status']
114
+ await ctx.info(f'Execution status: {status}')
115
+
116
+ if status == 'SUCCEEDED':
117
+ output = execution['output']
118
+ return format_state_machine_response(state_machine_name, output.encode())
119
+ elif status in ['FAILED', 'TIMED_OUT', 'ABORTED']:
120
+ error_message = (
121
+ f'State machine {state_machine_name} execution failed with status: {status}'
122
+ )
123
+ if 'error' in execution:
124
+ error_message += f', error: {execution["error"]}'
125
+ if 'cause' in execution:
126
+ error_message += f', cause: {execution["cause"]}'
127
+ await ctx.error(error_message)
128
+ return error_message
129
+
130
+ # Wait before checking again
131
+ await asyncio.sleep(1)
132
+
133
+
134
+ async def invoke_express_state_machine_impl(
135
+ state_machine_name: str, state_machine_arn: str, parameters: dict, ctx: Context
136
+ ) -> str:
137
+ """Execute an Express state machine using StartSyncExecution."""
138
+ await ctx.info(f'Starting synchronous execution of Express state machine {state_machine_name}')
139
+
140
+ # Start synchronous execution
141
+ response = sfn_client.start_sync_execution(
142
+ stateMachineArn=state_machine_arn,
143
+ input=json.dumps(parameters),
144
+ )
145
+
146
+ # Check execution status
147
+ status = response['status']
148
+ await ctx.info(f'Express execution completed with status: {status}')
149
+
150
+ if status == 'SUCCEEDED':
151
+ output = response['output']
152
+ return format_state_machine_response(state_machine_name, output.encode())
153
+ else:
154
+ error_message = (
155
+ f'Express state machine {state_machine_name} execution failed with status: {status}'
156
+ )
157
+ if 'error' in response:
158
+ error_message += f', error: {response["error"]}'
159
+ if 'cause' in response:
160
+ error_message += f', cause: {response["cause"]}'
161
+ await ctx.error(error_message)
162
+ return error_message
163
+
164
+
165
+ def get_schema_from_registry(schema_arn: str) -> Optional[dict]:
166
+ """Fetch schema from EventBridge Schema Registry.
167
+
168
+ Args:
169
+ schema_arn: ARN of the schema to fetch
170
+
171
+ Returns:
172
+ Schema content if successful, None if failed
173
+ """
174
+ try:
175
+ # Parse registry name and schema name from ARN
176
+ # ARN format: arn:aws:schemas:region:account:schema/registry-name/schema-name
177
+ arn_parts = schema_arn.split(':')
178
+ if len(arn_parts) < 6:
179
+ logger.error(f'Invalid schema ARN format: {schema_arn}')
180
+ return None
181
+
182
+ registry_schema = arn_parts[5].split('/')
183
+ if len(registry_schema) != 3:
184
+ logger.error(f'Invalid schema path in ARN: {arn_parts[5]}')
185
+ return None
186
+
187
+ registry_name = registry_schema[1]
188
+ schema_name = registry_schema[2]
189
+
190
+ # Get the latest schema version
191
+ response = schemas_client.describe_schema(
192
+ RegistryName=registry_name,
193
+ SchemaName=schema_name,
194
+ )
195
+
196
+ # Return the raw schema content
197
+ return response['Content']
198
+
199
+ except Exception as e:
200
+ logger.error(f'Error fetching schema from registry: {e}')
201
+ return None
202
+
203
+
204
+ def create_state_machine_tool(
205
+ state_machine_name: str,
206
+ state_machine_arn: str,
207
+ state_machine_type: str,
208
+ description: str,
209
+ schema_arn: Optional[str] = None,
210
+ ):
211
+ """Create a tool function for a Step Functions state machine.
212
+
213
+ Args:
214
+ state_machine_name: Name of the Step Functions state machine
215
+ state_machine_arn: ARN of the Step Functions state machine
216
+ state_machine_type: Type of the state machine (STANDARD or EXPRESS)
217
+ description: Base description for the tool
218
+ schema_arn: Optional ARN of the input schema in the Schema Registry
219
+ """
220
+ # Create a meaningful tool name
221
+ tool_name = sanitize_tool_name(state_machine_name)
222
+
223
+ # Define the inner function
224
+ async def state_machine_function(parameters: dict, ctx: Context) -> str:
225
+ """Tool for invoking a specific AWS Step Functions state machine with parameters."""
226
+ # Use the appropriate implementation based on state machine type
227
+ if state_machine_type == 'EXPRESS':
228
+ return await invoke_express_state_machine_impl(
229
+ state_machine_name, state_machine_arn, parameters, ctx
230
+ )
231
+ else: # STANDARD
232
+ return await invoke_standard_state_machine_impl(
233
+ state_machine_name, state_machine_arn, parameters, ctx
234
+ )
235
+
236
+ # Set the function's documentation
237
+ if schema_arn:
238
+ schema = get_schema_from_registry(schema_arn)
239
+ if schema:
240
+ # We add the schema to the description because mcp.tool does not expose overriding the tool schema.
241
+ description_with_schema = f'{description}\n\nInput Schema:\n{schema}'
242
+ state_machine_function.__doc__ = description_with_schema
243
+ logger.info(
244
+ f'Added schema from registry to description for state machine {state_machine_name}'
245
+ )
246
+ else:
247
+ state_machine_function.__doc__ = description
248
+ else:
249
+ state_machine_function.__doc__ = description
250
+
251
+ logger.info(f'Registering tool {tool_name} with description: {description}')
252
+ # Apply the decorator manually with the specific name
253
+ decorated_function = mcp.tool(name=tool_name)(state_machine_function)
254
+
255
+ return decorated_function
256
+
257
+
258
+ def get_schema_arn_from_state_machine_arn(state_machine_arn: str) -> Optional[str]:
259
+ """Get schema ARN from state machine tags if configured.
260
+
261
+ Args:
262
+ state_machine_arn: ARN of the Step Functions state machine
263
+
264
+ Returns:
265
+ Schema ARN if found and configured, None otherwise
266
+ """
267
+ if not STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY:
268
+ logger.info(
269
+ 'No schema tag environment variable provided (STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY ).'
270
+ )
271
+ return None
272
+
273
+ try:
274
+ tags_response = sfn_client.list_tags_for_resource(resourceArn=state_machine_arn)
275
+ tags = {tag['key']: tag['value'] for tag in tags_response.get('tags', [])}
276
+ if STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY in tags:
277
+ return tags[STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY]
278
+ else:
279
+ logger.info(
280
+ f'No schema arn provided for state machine {state_machine_arn} via tag {STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY}'
281
+ )
282
+ except Exception as e:
283
+ logger.warning(f'Error checking tags for state machine {state_machine_arn}: {e}')
284
+
285
+ return None
286
+
287
+
288
+ def filter_state_machines_by_tag(state_machines, tag_key, tag_value):
289
+ """Filter Step Functions state machines by a specific tag key-value pair.
290
+
291
+ Args:
292
+ state_machines: List of Step Functions state machine objects
293
+ tag_key: Tag key to filter by
294
+ tag_value: Tag value to filter by
295
+
296
+ Returns:
297
+ List of Step Functions state machines that have the specified tag key-value pair
298
+ """
299
+ logger.info(f'Filtering state machines by tag key-value pair: {tag_key}={tag_value}')
300
+ tagged_state_machines = []
301
+
302
+ for state_machine in state_machines:
303
+ try:
304
+ # Get tags for the state machine
305
+ tags_response = sfn_client.list_tags_for_resource(
306
+ resourceArn=state_machine['stateMachineArn']
307
+ )
308
+ tags = {tag['key']: tag['value'] for tag in tags_response.get('tags', [])}
309
+
310
+ # Check if the state machine has the specified tag key-value pair
311
+ if tag_key in tags and tags[tag_key] == tag_value:
312
+ tagged_state_machines.append(state_machine)
313
+ except Exception as e:
314
+ logger.warning(f'Error getting tags for state machine {state_machine["name"]}: {e}')
315
+
316
+ logger.info(
317
+ f'{len(tagged_state_machines)} Step Functions state machines found with tag {tag_key}={tag_value}.'
318
+ )
319
+ return tagged_state_machines
320
+
321
+
322
+ def register_state_machines():
323
+ """Register Step Functions state machines as individual tools."""
324
+ try:
325
+ logger.info('Registering Step Functions state machines as individual tools...')
326
+ state_machines = sfn_client.list_state_machines()
327
+
328
+ # Get all state machines
329
+ all_state_machines = state_machines['stateMachines']
330
+ logger.info(f'Total Step Functions state machines found: {len(all_state_machines)}')
331
+
332
+ # First filter by state machine name if prefix or list is set
333
+ if STATE_MACHINE_PREFIX or STATE_MACHINE_LIST:
334
+ valid_state_machines = [
335
+ sm for sm in all_state_machines if validate_state_machine_name(sm['name'])
336
+ ]
337
+ logger.info(
338
+ f'{len(valid_state_machines)} Step Functions state machines found after name filtering.'
339
+ )
340
+ else:
341
+ valid_state_machines = all_state_machines
342
+ logger.info(
343
+ 'No name filtering applied (both STATE_MACHINE_PREFIX and STATE_MACHINE_LIST are empty).'
344
+ )
345
+
346
+ # Then filter by tag if both STATE_MACHINE_TAG_KEY and STATE_MACHINE_TAG_VALUE are set and non-empty
347
+ if STATE_MACHINE_TAG_KEY and STATE_MACHINE_TAG_VALUE:
348
+ tagged_state_machines = filter_state_machines_by_tag(
349
+ valid_state_machines, STATE_MACHINE_TAG_KEY, STATE_MACHINE_TAG_VALUE
350
+ )
351
+ valid_state_machines = tagged_state_machines
352
+ elif STATE_MACHINE_TAG_KEY or STATE_MACHINE_TAG_VALUE:
353
+ logger.warning(
354
+ 'Both STATE_MACHINE_TAG_KEY and STATE_MACHINE_TAG_VALUE must be set to filter by tag.'
355
+ )
356
+ valid_state_machines = []
357
+
358
+ for state_machine in valid_state_machines:
359
+ state_machine_name = state_machine['name']
360
+ state_machine_arn = state_machine['stateMachineArn']
361
+
362
+ # Get state machine description from describe_state_machine
363
+ try:
364
+ state_machine_details = sfn_client.describe_state_machine(
365
+ stateMachineArn=state_machine_arn
366
+ )
367
+ description = state_machine_details.get(
368
+ 'description', f'AWS Step Functions state machine: {state_machine_name}'
369
+ )
370
+ # Parse definition and get Comment if present
371
+ definition = json.loads(state_machine_details.get('definition', '{}'))
372
+ if 'Comment' in definition:
373
+ description = f'{description}\n\nWorkflow Description: {definition["Comment"]}'
374
+ except Exception as e:
375
+ logger.warning(
376
+ f'Error getting details for state machine {state_machine_name}: {e}'
377
+ )
378
+ description = f'AWS Step Functions state machine: {state_machine_name}'
379
+
380
+ schema_arn = get_schema_arn_from_state_machine_arn(state_machine_arn)
381
+ create_state_machine_tool(
382
+ state_machine_name,
383
+ state_machine_arn,
384
+ state_machine['type'],
385
+ description,
386
+ schema_arn,
387
+ )
388
+
389
+ logger.info('Step Functions state machines registered successfully as individual tools.')
390
+
391
+ except Exception as e:
392
+ logger.error(f'Error registering Step Functions state machines as tools: {e}')
393
+
394
+
395
+ def main():
396
+ """Run the MCP server."""
397
+ register_state_machines()
398
+ mcp.run()
399
+
400
+
401
+ if __name__ == '__main__':
402
+ main()
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.4
2
+ Name: awslabs.stepfunctions-tool-mcp-server
3
+ Version: 0.1.4
4
+ Summary: An AWS Labs Model Context Protocol (MCP) server for AWS Step Functions
5
+ Project-URL: Homepage, https://awslabs.github.io/mcp/
6
+ Project-URL: Documentation, https://awslabs.github.io/mcp/servers/stepfunctions-tool-mcp-server/
7
+ Project-URL: Source, https://github.com/awslabs/mcp.git
8
+ Project-URL: Bug Tracker, https://github.com/awslabs/mcp/issues
9
+ Project-URL: Changelog, https://github.com/awslabs/mcp/blob/main/src/stepfunctions-tool-mcp-server/CHANGELOG.md
10
+ Author: Amazon Web Services
11
+ Author-email: AWSLabs MCP <203918161+awslabs-mcp@users.noreply.github.com>
12
+ License: Apache-2.0
13
+ License-File: LICENSE
14
+ License-File: NOTICE
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: boto3>=1.37.27
25
+ Requires-Dist: mcp[cli]>=1.6.0
26
+ Requires-Dist: pydantic>=2.10.6
27
+ Description-Content-Type: text/markdown
28
+
29
+ # AWS Step Functions Tool MCP Server
30
+
31
+ A Model Context Protocol (MCP) server for AWS Step Functions to select and run state machines as MCP tools without code changes.
32
+
33
+ ## Features
34
+
35
+ This MCP server acts as a **bridge** between MCP clients and AWS Step Functions state machines, allowing generative AI models to access and run state machines as tools. This enables seamless integration with existing Step Function workflows without requiring any modifications to their definitions. Through this bridge, AI models can execute and manage complex, multi-step business processes that coordinate operations across multiple AWS services.
36
+
37
+ The server supports both Standard and Express workflows, adapting to different execution needs. Standard workflows excel at long-running processes where status tracking is essential, while Express workflows handle high-volume, short-duration tasks with synchronous execution. This flexibility ensures optimal handling of various workflow patterns and requirements.
38
+
39
+ To ensure data quality and provide clear documentation, the server integrates with EventBridge Schema Registry for input validation. It combines schema information with state machine definitions to generate comprehensive tool documentation, helping AI models understand both the purpose and technical requirements of each workflow.
40
+
41
+ From a security perspective, the server implements IAM-based authentication and authorization, creating a clear separation of duties. While models can invoke state machines through the MCP server, they don't have direct access to other AWS services. Instead, the state machines themselves handle AWS service interactions using their own IAM roles, maintaining robust security boundaries while enabling powerful workflow capabilities.
42
+
43
+ ```mermaid
44
+ graph LR
45
+ A[Model] <--> B[MCP Client]
46
+ B <--> C["MCP2StepFunctions<br>(MCP Server)"]
47
+ C <--> D[State Machine]
48
+ D <--> E[Other AWS Services]
49
+ D <--> F[Internet]
50
+ D <--> G[VPC]
51
+
52
+ style A fill:#f9f,stroke:#333,stroke-width:2px
53
+ style B fill:#bbf,stroke:#333,stroke-width:2px
54
+ style C fill:#bfb,stroke:#333,stroke-width:4px
55
+ style D fill:#fbb,stroke:#333,stroke-width:2px
56
+ style E fill:#fbf,stroke:#333,stroke-width:2px
57
+ style F fill:#dff,stroke:#333,stroke-width:2px
58
+ style G fill:#ffd,stroke:#333,stroke-width:2px
59
+ ```
60
+
61
+ ## Prerequisites
62
+
63
+ 1. Install `uv` from [Astral](https://docs.astral.sh/uv/getting-started/installation/) or the [GitHub README](https://github.com/astral-sh/uv#installation)
64
+ 2. Install Python using `uv python install 3.10`
65
+
66
+ ## Installation
67
+
68
+ Here are some ways you can work with MCP across AWS, and we'll be adding support to more products including Amazon Q Developer CLI soon: (e.g. for Amazon Q Developer CLI MCP, `~/.aws/amazonq/mcp.json`):
69
+
70
+ ```json
71
+ {
72
+ "mcpServers": {
73
+ "awslabs.stepfunctions-tool-mcp-server": {
74
+ "command": "uvx",
75
+ "args": ["awslabs.stepfunctions-tool-mcp-server@latest"],
76
+ "env": {
77
+ "AWS_PROFILE": "your-aws-profile",
78
+ "AWS_REGION": "us-east-1",
79
+ "STATE_MACHINE_PREFIX": "your-state-machine-prefix",
80
+ "STATE_MACHINE_LIST": "your-first-state-machine, your-second-state-machine",
81
+ "STATE_MACHINE_TAG_KEY": "your-tag-key",
82
+ "STATE_MACHINE_TAG_VALUE": "your-tag-value",
83
+ "STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY": "your-state-machine-tag-for-input-schema"
84
+ }
85
+ }
86
+ }
87
+ }
88
+ ```
89
+
90
+ or docker after a successful `docker build -t awslabs/stepfunctions-tool-mcp-server .`:
91
+
92
+ ```file
93
+ # fictitious `.env` file with AWS temporary credentials
94
+ AWS_ACCESS_KEY_ID=ASIAIOSFODNN7EXAMPLE
95
+ AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
96
+ AWS_SESSION_TOKEN=AQoEXAMPLEH4aoAH0gNCAPy...truncated...zrkuWJOgQs8IZZaIv2BXIa2R4Olgk
97
+ ```
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "awslabs.stepfunctions-tool-mcp-server": {
103
+ "command": "docker",
104
+ "args": [
105
+ "run",
106
+ "--rm",
107
+ "--interactive",
108
+ "--env",
109
+ "AWS_REGION=us-east-1",
110
+ "--env",
111
+ "STATE_MACHINE_PREFIX=your-state-machine-prefix",
112
+ "--env",
113
+ "STATE_MACHINE_LIST=your-first-state-machine,your-second-state-machine",
114
+ "--env",
115
+ "STATE_MACHINE_TAG_KEY=your-tag-key",
116
+ "--env",
117
+ "STATE_MACHINE_TAG_VALUE=your-tag-value",
118
+ "--env",
119
+ "STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY=your-state-machine-tag-for-input-schema",
120
+ "--env-file",
121
+ "/full/path/to/file/above/.env",
122
+ "awslabs/stepfunctions-tool-mcp-server:latest"
123
+ ],
124
+ "env": {},
125
+ "disabled": false,
126
+ "autoApprove": []
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ NOTE: Your credentials will need to be kept refreshed from your host
133
+
134
+ The `AWS_PROFILE` and the `AWS_REGION` are optional, their default values are `default` and `us-east-1`.
135
+
136
+ You can specify `STATE_MACHINE_PREFIX`, `STATE_MACHINE_LIST`, or both. If both are empty, all state machines pass the name check.
137
+ After the name check, if both `STATE_MACHINE_TAG_KEY` and `STATE_MACHINE_TAG_VALUE` are set, state machines are further filtered by tag (with key=value).
138
+ If only one of `STATE_MACHINE_TAG_KEY` and `STATE_MACHINE_TAG_VALUE`, then no state machine is selected and a warning is displayed.
139
+
140
+ ## Tool Documentation
141
+
142
+ The MCP server builds comprehensive tool documentation by combining multiple sources of information to help AI models understand and use state machines effectively.
143
+
144
+ 1. **State Machine Description**: The state machine's description field provides the base tool description. For example:
145
+ ```plaintext
146
+ Retrieve customer status on the CRM system based on { 'customerId' } or { 'customerEmail' }
147
+ ```
148
+
149
+ 2. **Workflow Description**: The Comment field from the state machine definition adds workflow context. For example:
150
+ ```json
151
+ {
152
+ "Comment": "This workflow first looks up a customer ID from email, then retrieves their info",
153
+ "StartAt": "GetCustomerId",
154
+ "States": { ... }
155
+ }
156
+ ```
157
+
158
+ 3. **Input Schema**: The server integrates with EventBridge Schema Registry to provide formal JSON Schema documentation for state machine inputs. To enable schema support:
159
+ - Create your schema in EventBridge Schema Registry
160
+ - Tag your state machine with the schema ARN:
161
+ ```plaintext
162
+ Key: STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY (configurable)
163
+ Value: arn:aws:schemas:region:account:schema/registry-name/schema-name
164
+ ```
165
+ - Configure the MCP server:
166
+ ```json
167
+ {
168
+ "env": {
169
+ "STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY": "your-schema-arn-tag-key"
170
+ }
171
+ }
172
+ ```
173
+
174
+ The server combines these sources into a unified documentation format:
175
+ ```plaintext
176
+ [State Machine Description]
177
+
178
+ Workflow Description: [Comment from state machine definition]
179
+
180
+ Input Schema:
181
+ [JSON Schema from EventBridge Schema Registry]
182
+ ```
183
+
184
+ This comprehensive documentation helps AI models understand both the purpose and technical requirements of each state machine, with formal schema support ensuring correct input formatting.
185
+
186
+ ## Best practices
187
+
188
+ - Use the `STATE_MACHINE_LIST` to specify the state machines that are available as MCP tools.
189
+ - Use the `STATE_MACHINE_PREFIX` to specify the prefix of the state machines that are available as MCP tools.
190
+ - Use the `STATE_MACHINE_TAG_KEY` and `STATE_MACHINE_TAG_VALUE` to specify the tag key and value of the state machines that are available as MCP tools.
191
+ - AWS Step Functions `Description` property: the description of the state machine is used as MCP tool description, so it should be very detailed to help the model understand when and how to use the state machine
192
+ - Add workflow documentation using the `Comment` field in state machine definitions:
193
+ - Describe the workflow's purpose and steps
194
+ - Explain any important logic or conditions
195
+ - Document expected inputs and outputs
196
+ - Use EventBridge Schema Registry to provide formal input definition:
197
+ - Create JSON Schema definitions for your state machine inputs
198
+ - Tag state machines with their schema ARNs
199
+ - Configure `STATE_MACHINE_INPUT_SCHEMA_ARN_TAG_KEY` in the MCP server
200
+
201
+ ## Security Considerations
202
+
203
+ When using this MCP server, you should consider:
204
+
205
+ - Only state machines that are in the provided list or with a name starting with the prefix are imported as MCP tools.
206
+ - The MCP server needs permissions to invoke the state machines.
207
+ - Each state machine has its own permissions to optionally access other AWS resources.
@@ -0,0 +1,9 @@
1
+ awslabs/__init__.py,sha256=4zfFn3N0BkvQmMTAIvV_QAbKp6GWzrwaUN17YeRoChM,115
2
+ awslabs/stepfunctions_tool_mcp_server/__init__.py,sha256=n0IrKZR35oICjSeI7vz7nq78OleFf8Rvo09My7d7SJY,67
3
+ awslabs/stepfunctions_tool_mcp_server/server.py,sha256=B0yqqtbRS-sKEFaGEUKtTLQ_c2zrCvVDfC5Ry1wc_f8,15474
4
+ awslabs_stepfunctions_tool_mcp_server-0.1.4.dist-info/METADATA,sha256=tvSFFB0f8U23p7W9tbNlt4kq553TOozKuHkIOiaCMOA,9698
5
+ awslabs_stepfunctions_tool_mcp_server-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ awslabs_stepfunctions_tool_mcp_server-0.1.4.dist-info/entry_points.txt,sha256=PVQOhNJ_2mgqvdXcqv2KS8Wa2-vZkjatVw0upZga7RU,108
7
+ awslabs_stepfunctions_tool_mcp_server-0.1.4.dist-info/licenses/LICENSE,sha256=CeipvOyAZxBGUsFoaFqwkx54aPnIKEtm9a5u2uXxEws,10142
8
+ awslabs_stepfunctions_tool_mcp_server-0.1.4.dist-info/licenses/NOTICE,sha256=9GfleTZWBLGtrNSl42TlT_fT7wPBajAx1OQdlIaXUkY,105
9
+ awslabs_stepfunctions_tool_mcp_server-0.1.4.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ awslabs.stepfunctions-tool-mcp-server = awslabs.stepfunctions_tool_mcp_server.server:main
@@ -0,0 +1,175 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
@@ -0,0 +1,2 @@
1
+ awslabs.stepfunctions-tool-mcp-server
2
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.