Integrate Spike’s health data into AI applications using the Model Context Protocol (MCP). The examples below show complete implementations for OpenAI and Anthropic clients, including authentication, server configuration, and data querying.
Requirements:
  • Spike JWT access token (see Authentication)
  • AI provider API key (OpenAI or Anthropic)
  • MCP server URL: https://app-api.spikeapi.com/v3/mcp

Using the Token

Include the JWT token in the Authorization header when configuring the MCP tool:
Authorization: Bearer <your_jwt_token>

OpenAI

curl -X POST "https://api.openai.com/v1/responses" \
  -H "Authorization: Bearer OPENAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "o4-mini",
    "instructions": "you are a health and wellness analyst.",
    "input": "Analyze my health data for 2025-08-17 and provide a summary of my health data.",
    "tools": [
      {
        "type": "mcp",
        "server_label": "spike-health-data",
        "server_url": "https://app-api.spikeapi.com/v3/mcp",
        "headers": {
          "Authorization": "Bearer SPIKE_ACCESS_TOKEN"
        },
        "server_description": "Health and fitness data analysis server providing daily and hourly statistics from connected wearables and health devices.",
        "require_approval": "never"
      }
    ],
    "tool_choice": "auto",
    "max_tool_calls": 1,
    "max_output_tokens": 5000,
    "parallel_tool_calls": true,
    "metadata": {
      "analysis_type": "daily_health_review",
      "date": "2025-08-17",
      "tools_used": "mcp_health_data",
      "version": "1.0.0"
    }
  }'

Anthropic

curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "X-API-Key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: mcp-client-2025-04-04" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "mcp_servers": [
      {
        "type": "url",
        "name": "spike-health-data",
        "url": "https://app-api.spikeapi.com/v3/mcp",
        "authorization_token": "SPIKE_ACCESS_TOKEN",
        "tool_configuration": {
          "enabled": true,
        }
      }
    ],
    "messages": [
      {
        "role": "user",
        "content": "Analyze my health data for 2025-08-17 and provide a summary of my health data."
      }
    ]
  }'