TESTING.mdā¢6.46 kB
# Testing the Luma MCP Server with curl
## Quick Start
### 1. Start the Development Server
```bash
npm run dev
```
Server runs at: `http://localhost:8787`
## MCP Protocol Basics
The MCP server uses JSON-RPC 2.0 protocol. All requests follow this format:
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "method_name",
"params": {
/* parameters */
}
}
```
## curl Examples
### List Available Tools
First, discover what tools are available:
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'
```
### Search Luma Events (All-in-One Tool)
**Your specific example - Search for events in San Francisco:**
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_luma_events",
"arguments": {
"query": "events",
"maxItems": 10,
"location": "San Francisco",
"timeoutSeconds": 60
}
}
}'
```
**Search for AI conferences:**
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_luma_events",
"arguments": {
"query": "AI conference",
"maxItems": 5
}
}
}'
```
**Search for Web3 events in Amsterdam:**
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_luma_events",
"arguments": {
"query": "Web3",
"maxItems": 10,
"location": "Amsterdam",
"timeoutSeconds": 90
}
}
}'
```
### Advanced: Multi-Step Workflow
For more control, use the 3-step workflow:
#### Step 1: Start a Scrape
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "start_luma_scrape",
"arguments": {
"query": "hackathon",
"maxItems": 10,
"location": "San Francisco"
}
}
}'
```
**Response will include a `runId`:**
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "{\"runId\":\"abc123...\",\"status\":\"RUNNING\",\"datasetId\":\"xyz789...\"}"
}
]
}
}
```
#### Step 2: Check Run Status
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "check_run_status",
"arguments": {
"runId": "PUT_RUN_ID_HERE"
}
}
}'
```
**Wait until status is `SUCCEEDED`**
#### Step 3: Get Results
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_scrape_results",
"arguments": {
"datasetId": "PUT_DATASET_ID_HERE",
"limit": 10
}
}
}'
```
## Testing Production Deployment
After deploying to Cloudflare Workers:
```bash
# Replace with your worker URL
WORKER_URL="https://luma-events-mcp.your-subdomain.workers.dev"
curl -X POST $WORKER_URL/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_luma_events",
"arguments": {
"query": "events",
"maxItems": 10,
"location": "San Francisco",
"timeoutSeconds": 60
}
}
}'
```
## Pretty Print JSON Responses
Add `jq` to format the JSON output nicely:
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_luma_events",
"arguments": {
"query": "events",
"maxItems": 10,
"location": "San Francisco"
}
}
}' | jq .
```
## Save Response to File
```bash
curl -X POST http://localhost:8787/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "search_luma_events",
"arguments": {
"query": "AI",
"maxItems": 20
}
}
}' > luma_events.json
```
## Bash Script for Quick Testing
Create `test.sh`:
```bash
#!/bin/bash
# Configuration
BASE_URL="http://localhost:8787/mcp"
QUERY="${1:-events}"
LOCATION="${2:-San Francisco}"
MAX_ITEMS="${3:-10}"
echo "Searching for: $QUERY in $LOCATION (max: $MAX_ITEMS)"
curl -X POST $BASE_URL \
-H "Content-Type: application/json" \
-d "{
\"jsonrpc\": \"2.0\",
\"id\": 1,
\"method\": \"tools/call\",
\"params\": {
\"name\": \"search_luma_events\",
\"arguments\": {
\"query\": \"$QUERY\",
\"maxItems\": $MAX_ITEMS,
\"location\": \"$LOCATION\",
\"timeoutSeconds\": 60
}
}
}" | jq .
```
Make it executable and use it:
```bash
chmod +x test.sh
# Examples:
./test.sh "AI conference" "San Francisco" 5
./test.sh "hackathon" "New York" 10
./test.sh "Web3"
```
## Expected Response Format
Successful response:
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "[{\"name\":\"Event Name\",\"url\":\"https://lu.ma/...\",\"start_at\":\"2024-...\",\"end_at\":\"2024-...\",\"location\":\"...\",\"geo\":{\"lat\":37.7749,\"lng\":-122.4194}}]"
}
]
}
}
```
Error response:
```json
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32603,
"message": "APIFY_API_TOKEN environment variable not set"
}
}
```
## Troubleshooting
### Connection Refused
- Make sure dev server is running: `npm run dev`
- Check the port (default: 8787)
### "APIFY_API_TOKEN environment variable not set"
- Verify `.dev.vars` exists and contains your token
- Restart the dev server
### Timeout Error
- Increase `timeoutSeconds` (default is 60)
- Large queries may take 30-90 seconds
### Empty Results
- Try a more general query (e.g., "events" instead of specific event names)
- Remove location filter to search globally