hcs_topic
Create, update, or subscribe to Hedera Consensus Service topics for managing message streams and configuring topic settings.
Instructions
Hedera Consensus Service (HCS) topic management.
OPERATIONS:
create: Create new public or private topic with configurable keys
update: Update topic memo or auto-renew period
subscribe: Subscribe to real-time topic messages
USE THIS FOR: Creating consensus topics, configuring topic settings, real-time message streams.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operation | Yes | Topic operation | |
| topicId | No | Topic ID (for update/subscribe) | |
| memo | No | Topic memo (max 100 bytes) | |
| adminKey | No | Enable admin key for updates/deletion | |
| submitKey | No | Enable submit key (makes topic private) | |
| autoRenewPeriod | No | Auto-renew period in seconds | |
| startTime | No | ISO 8601 timestamp to start receiving messages |
Implementation Reference
- src/tools/composite.ts:268-319 (handler)Primary handler function for the 'hcs_topic' tool. Routes to specific HCS topic operations (create, update, subscribe, info) by delegating to consensusTools.export async function hcsTopicManage(args: { operation: 'create' | 'update' | 'subscribe' | 'info'; // Common topicId?: string; // Create specific memo?: string; adminKey?: boolean; submitKey?: boolean; autoRenewPeriod?: number; // Update specific // Subscribe specific startTime?: string; }): Promise<ToolResult> { try { logger.info('HCS topic operation', { operation: args.operation }); switch (args.operation) { case 'create': return await consensusTools.createTopic({ memo: args.memo, adminKey: args.adminKey, submitKey: args.submitKey, autoRenewPeriod: args.autoRenewPeriod, }); case 'update': return await consensusTools.updateTopic({ topicId: args.topicId!, memo: args.memo, autoRenewPeriod: args.autoRenewPeriod, }); case 'subscribe': return await consensusTools.subscribeToTopic({ topicId: args.topicId!, startTime: args.startTime, }); default: return { success: false, error: `Unknown topic operation: ${args.operation}`, }; } } catch (error) { logger.error('HCS topic operation failed', { operation: args.operation, error }); return { success: false, error: error instanceof Error ? error.message : 'Unknown error', }; } }
- src/tools/composite.ts:549-594 (schema)Tool definition including name, description, and input schema for 'hcs_topic' used in MCP tool listing.{ name: 'hcs_topic', description: `Hedera Consensus Service (HCS) topic management. OPERATIONS: - create: Create new public or private topic with configurable keys - update: Update topic memo or auto-renew period - subscribe: Subscribe to real-time topic messages USE THIS FOR: Creating consensus topics, configuring topic settings, real-time message streams.`, inputSchema: { type: 'object' as const, properties: { operation: { type: 'string', enum: ['create', 'update', 'subscribe'], description: 'Topic operation', }, topicId: { type: 'string', description: 'Topic ID (for update/subscribe)', }, memo: { type: 'string', description: 'Topic memo (max 100 bytes)', }, adminKey: { type: 'boolean', description: 'Enable admin key for updates/deletion', }, submitKey: { type: 'boolean', description: 'Enable submit key (makes topic private)', }, autoRenewPeriod: { type: 'number', description: 'Auto-renew period in seconds', }, startTime: { type: 'string', description: 'ISO 8601 timestamp to start receiving messages', }, }, required: ['operation'], }, },
- src/index.ts:597-598 (registration)Dispatcher switch case in MCP server that routes calls to 'hcs_topic' tool to the hcsTopicManage handler.case 'hcs_topic': result = await hcsTopicManage(args as any);
- src/index.ts:219-220 (registration)Inclusion of compositeToolDefinitions (containing 'hcs_topic') into the optimizedToolDefinitions array for MCP listTools handler.// Composite Tools (5 tools - consolidated from 24) ...compositeToolDefinitions,
- src/index.ts:37-37 (registration)Import of hcsTopicManage handler from composite.ts into the main MCP server index.hcsTopicManage,