generate_indexer
Create subgraph code to index Arbitrum smart contracts for The Graph, enabling blockchain data querying and analysis.
Instructions
Generate subgraph code for indexing Arbitrum contracts with The Graph.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Description of the indexing requirements | |
| template | No | Type of subgraph template to use | |
| contract_address | No | Contract address to index | |
| contract_abi | No | Contract ABI JSON string for custom events | |
| start_block | No | Block number to start indexing from | |
| network | No | Network to deploy the subgraph | arbitrum-sepolia |
Implementation Reference
- src/mcp/tools/generate_indexer.py:83-139 (handler)The execute method in GenerateIndexerTool handles the generation of subgraph indexing code, including template selection and customization.
def execute(self, **kwargs) -> dict[str, Any]: """Generate subgraph code based on the request.""" prompt = kwargs.get("prompt", "") template_name = kwargs.get("template") contract_address = kwargs.get("contract_address", "0x0000000000000000000000000000000000000000") contract_abi = kwargs.get("contract_abi") start_block = kwargs.get("start_block", 0) network = kwargs.get("network", "arbitrum-sepolia") events = kwargs.get("events", []) # Validate inputs if not prompt: return {"error": "prompt is required"} # Select template if template_name: template = get_indexer_template(template_name) if not template: return {"error": f"Unknown template: {template_name}"} else: template = select_indexer_template(prompt) # Context retrieval (template-based generation doesn't require RAG) context = [] # Customize template files = self._customize_template( template, prompt, contract_address, contract_abi, start_block, network, events, ) # Build response result = { "template_used": template.name, "template_type": template.template_type, "files": files, "dependencies": template.dependencies, "networks": template.networks, "setup_instructions": self._get_setup_instructions(template, network), "deployment_commands": self._get_deployment_commands(network), } if context: result["references"] = [ { "source": c.get("metadata", {}).get("source", "Unknown"), "relevance": c.get("distance", 0), } for c in context[:3] ] return result - The input_schema defines the expected parameters for the generate_indexer tool, such as prompt, template type, contract details, and networking configuration.
input_schema = { "type": "object", "properties": { "prompt": { "type": "string", "description": "Description of the indexing requirements", }, "template": { "type": "string", "enum": ["erc20", "erc721", "defi", "custom"], "description": "Type of subgraph template to use", }, "contract_address": { "type": "string", "description": "Contract address to index", }, "contract_abi": { "type": "string", "description": "Contract ABI JSON string for custom events", }, "start_block": { "type": "integer", "description": "Block number to start indexing from", "default": 0, }, "network": { "type": "string", "enum": ["arbitrum-one", "arbitrum-sepolia"], "description": "Network to deploy the subgraph", "default": "arbitrum-sepolia", }, "events": { "type": "array", "items": {"type": "string"}, "description": "List of event names to index (for custom template)", }, }, "required": ["prompt"], } - src/mcp/server.py:889-889 (registration)The generate_indexer tool is registered in the MCP server's tools dictionary.
"generate_indexer": GenerateIndexerTool(),