Update MCP server CLI and example script to include card_table_id in request handling

- Add card_table_id to the required properties in MCPServer class.
- Modify the move_column method to retrieve card_table_id from arguments.
- Refactor subprocess call in card_table_example.py to use subprocess.run for better error handling.
This commit is contained in:
George Antonopoulos
2025-06-29 08:37:41 +01:00
parent a439865ef4
commit b740378a90
2 changed files with 10 additions and 11 deletions

View File

@@ -25,20 +25,20 @@ def send_mcp_request(method, params=None):
} }
# Run the MCP server with the request # Run the MCP server with the request
process = subprocess.Popen( result = subprocess.run(
[sys.executable, "mcp_server_cli.py"], [sys.executable, "mcp_server_cli.py"],
stdin=subprocess.PIPE, input=json.dumps(request),
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
text=True text=True
) )
stdout, stderr = process.communicate(input=json.dumps(request)) if result.returncode != 0:
print(f"Error: {result.stderr}")
if process.returncode != 0:
print(f"Error: {stderr}")
return None return None
stdout = result.stdout
try: try:
return json.loads(stdout) return json.loads(stdout)
except json.JSONDecodeError as e: except json.JSONDecodeError as e:

View File

@@ -240,10 +240,11 @@ class MCPServer:
"type": "object", "type": "object",
"properties": { "properties": {
"project_id": {"type": "string", "description": "The project ID"}, "project_id": {"type": "string", "description": "The project ID"},
"card_table_id": {"type": "string", "description": "The card table ID"},
"column_id": {"type": "string", "description": "The column ID"}, "column_id": {"type": "string", "description": "The column ID"},
"position": {"type": "integer", "description": "The new 1-based position"} "position": {"type": "integer", "description": "The new 1-based position"}
}, },
"required": ["project_id", "column_id", "position"] "required": ["project_id", "card_table_id", "column_id", "position"]
} }
}, },
{ {
@@ -840,16 +841,14 @@ class MCPServer:
return { return {
"status": "success", "status": "success",
"column": column, "column": column,
"message": f"Column updated successfully" "message": "Column updated successfully"
} }
elif tool_name == "move_column": elif tool_name == "move_column":
project_id = arguments.get("project_id") project_id = arguments.get("project_id")
card_table_id = arguments.get("card_table_id")
column_id = arguments.get("column_id") column_id = arguments.get("column_id")
position = arguments.get("position") position = arguments.get("position")
# Get the card table ID from the project
card_table = client.get_card_table(project_id)
card_table_id = card_table['id']
client.move_column(project_id, column_id, position, card_table_id) client.move_column(project_id, column_id, position, card_table_id)
return { return {
"status": "success", "status": "success",