hcs_query
Query Hedera Consensus Service topics using natural language questions to retrieve AI-ranked relevant messages with plain English summaries.
Instructions
Query an HCS topic with a natural language question. Returns AI-ranked relevant messages and a plain English summary. Costs 0.05 HBAR.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | Yes | Your HederaIntel API key | |
| query | Yes | Natural language question about the topic | |
| topic_id | No | Hedera topic ID (e.g. 0.0.8026796). Defaults to the HederaIntel platform topic. | |
| limit | No | Max messages to retrieve (default 50) |
Implementation Reference
- src/modules/hcs/tools.js:72-89 (handler)The handler function for "hcs_query" that processes the tool logic, including payment charging, message retrieval, and analysis.
if (name === "hcs_query") { const payment = chargeForTool("hcs_query", args.api_key); const topicId = args.topic_id || PLATFORM_TOPIC; const messages = await getTopicMessages(topicId, args.limit || 50); const analysis = await analyzeMessages(messages, args.query); return { topic_id: topicId, query: args.query, messages_retrieved: messages.length, messages_relevant: analysis.relevant_messages?.length || 0, summary: analysis.summary, anomalies: analysis.anomalies, recommended_action: analysis.recommended_action, relevant_messages: analysis.relevant_messages || [], payment, timestamp: new Date().toISOString(), }; } - src/modules/hcs/tools.js:21-34 (schema)The input schema definition for "hcs_query", including properties like topic_id, query, limit, and api_key.
{ name: "hcs_query", description: "Query an HCS topic with a natural language question. Returns AI-ranked relevant messages and a plain English summary. Costs 0.1 HBAR.", inputSchema: { type: "object", properties: { topic_id: { type: "string", description: "Hedera topic ID (e.g. 0.0.8026796). Defaults to the HederaIntel platform topic." }, query: { type: "string", description: "Natural language question about the topic" }, limit: { type: "number", description: "Max messages to retrieve (default 50)" }, api_key: { type: "string", description: "Your HederaIntel API key" }, }, required: ["query", "api_key"], }, },