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:
@@ -25,20 +25,20 @@ def send_mcp_request(method, params=None):
|
||||
}
|
||||
|
||||
# Run the MCP server with the request
|
||||
process = subprocess.Popen(
|
||||
result = subprocess.run(
|
||||
[sys.executable, "mcp_server_cli.py"],
|
||||
stdin=subprocess.PIPE,
|
||||
input=json.dumps(request),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True
|
||||
)
|
||||
|
||||
stdout, stderr = process.communicate(input=json.dumps(request))
|
||||
|
||||
if process.returncode != 0:
|
||||
print(f"Error: {stderr}")
|
||||
if result.returncode != 0:
|
||||
print(f"Error: {result.stderr}")
|
||||
return None
|
||||
|
||||
stdout = result.stdout
|
||||
|
||||
try:
|
||||
return json.loads(stdout)
|
||||
except json.JSONDecodeError as e:
|
||||
|
||||
@@ -240,10 +240,11 @@ class MCPServer:
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"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"},
|
||||
"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 {
|
||||
"status": "success",
|
||||
"column": column,
|
||||
"message": f"Column updated successfully"
|
||||
"message": "Column updated successfully"
|
||||
}
|
||||
|
||||
elif tool_name == "move_column":
|
||||
project_id = arguments.get("project_id")
|
||||
card_table_id = arguments.get("card_table_id")
|
||||
column_id = arguments.get("column_id")
|
||||
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)
|
||||
return {
|
||||
"status": "success",
|
||||
|
||||
Reference in New Issue
Block a user