#!/bin/bash
# Invoke mcp__trello__get_card via the claude-code infrastructure
# This assumes claude-code is running and we can reach the MCP bridge

card_id="6a1d695cd72ebc9eb5f6526b"

# Try to invoke via the MCP HTTP bridge if available
# The default endpoint is typically localhost:3001 but may vary

for port in 3001 3000 8000 9000; do
  if timeout 2 bash -c "echo > /dev/tcp/127.0.0.1/$port" 2>/dev/null; then
    echo "Found service on port $port"
    curl -s -X POST "http://127.0.0.1:$port/mcp/invoke" \
      -H "Content-Type: application/json" \
      -d "{
        \"server\": \"mcp__trello__get_card\",
        \"tool\": \"mcp__trello__get_card\",
        \"input\": {
          \"cardId\": \"$card_id\",
          \"includeMarkdown\": true
        }
      }" 2>/dev/null && exit 0
  fi
done

echo "Could not reach MCP bridge on common ports" >&2
exit 1
