agent-mcp-sql / seed_localhost.py
Timothy Eastridge
commit step 6
84473fd
raw
history blame
2.32 kB
import requests
import json
MCP_URL = "http://localhost:8000/mcp"
API_KEY = "dev-key-123"
def call_mcp(tool, params=None):
response = requests.post(
MCP_URL,
headers={"X-API-Key": API_KEY, "Content-Type": "application/json"},
json={"tool": tool, "params": params or {}}
)
return response.json()
# Create demo workflow
workflow = call_mcp("write_graph", {
"action": "create_node",
"label": "Workflow",
"properties": {
"id": "demo-workflow-1",
"name": "Entity Resolution Demo",
"status": "active",
"max_iterations": 10,
"current_iteration": 0
}
})
print(f"Created workflow: {workflow}")
# Create three instructions
instructions = [
{"id": "inst-1", "sequence": 1, "type": "discover_schema", "status": "pending", "pause_duration": 300},
{"id": "inst-2", "sequence": 2, "type": "generate_sql", "status": "pending", "pause_duration": 300},
{"id": "inst-3", "sequence": 3, "type": "review_results", "status": "pending", "pause_duration": 300}
]
for inst in instructions:
result = call_mcp("write_graph", {
"action": "create_node",
"label": "Instruction",
"properties": inst
})
print(f"Created instruction: {inst['id']}")
# Link to workflow
call_mcp("query_graph", {
"query": '''
MATCH (w:Workflow {id: }), (i:Instruction {id: })
CREATE (w)-[:HAS_INSTRUCTION]->(i)
''',
"parameters": {"wid": "demo-workflow-1", "iid": inst['id']}
})
# Create instruction chain
call_mcp("query_graph", {
"query": '''
MATCH (i1:Instruction {id: 'inst-1'}), (i2:Instruction {id: 'inst-2'})
CREATE (i1)-[:NEXT_INSTRUCTION]->(i2)
'''
})
call_mcp("query_graph", {
"query": '''
MATCH (i2:Instruction {id: 'inst-2'}), (i3:Instruction {id: 'inst-3'})
CREATE (i2)-[:NEXT_INSTRUCTION]->(i3)
'''
})
# Create indexes
call_mcp("query_graph", {"query": "CREATE INDEX workflow_id IF NOT EXISTS FOR (w:Workflow) ON (w.id)"})
call_mcp("query_graph", {"query": "CREATE INDEX instruction_id IF NOT EXISTS FOR (i:Instruction) ON (i.id)"})
call_mcp("query_graph", {"query": "CREATE INDEX instruction_status_seq IF NOT EXISTS FOR (i:Instruction) ON (i.status, i.sequence)"})
print(" Seeding complete!")