import { z } from 'zod';
import { CCExplorerClient } from './api-client.js';
// Tool definitions
export const tools = [
// === Consensus ===
{
name: 'consensus_get',
description: 'Get the latest consensus block and validator set from the Canton Network',
inputSchema: z.object({}),
handler: async (client: CCExplorerClient) => {
return await client.getConsensus();
},
},
// === Contracts ===
{
name: 'contract_get',
description: 'Get details of a specific contract by ID',
inputSchema: z.object({
id: z.string().describe('The contract ID'),
}),
handler: async (client: CCExplorerClient, args: { id: string }) => {
return await client.getContract(args.id);
},
},
// === Updates ===
{
name: 'contract_updates_list',
description: 'List updates involving a specific contract',
inputSchema: z.object({
id: z.string().describe('The contract ID'),
limit: z.number().optional().describe('Maximum number of results'),
offset: z.number().optional().describe('Number of items to skip'),
}),
handler: async (client: CCExplorerClient, args: { id: string; limit?: number; offset?: number }) => {
return await client.getContractUpdates(args.id, args.limit, args.offset);
},
},
{
name: 'party_updates_list',
description: 'List updates involving a specific party',
inputSchema: z.object({
id: z.string().describe('The party ID'),
limit: z.number().optional().describe('Maximum number of results'),
offset: z.number().optional().describe('Number of items to skip'),
}),
handler: async (client: CCExplorerClient, args: { id: string; limit?: number; offset?: number }) => {
return await client.getPartyUpdates(args.id, args.limit, args.offset);
},
},
{
name: 'update_get',
description: 'Get a specific ledger update by ID',
inputSchema: z.object({
update_id: z.string().describe('The update ID'),
}),
handler: async (client: CCExplorerClient, args: { update_id: string }) => {
return await client.getUpdateDetail(args.update_id);
},
},
{
name: 'updates_list',
description: 'List ledger updates',
inputSchema: z.object({
limit: z.number().optional().describe('Maximum number of results'),
offset: z.number().optional().describe('Number of items to skip'),
}),
handler: async (client: CCExplorerClient, args: { limit?: number; offset?: number }) => {
return await client.getUpdates(args.limit, args.offset);
},
},
// === Rounds ===
{
name: 'round_current',
description: 'Get the current round number',
inputSchema: z.object({}),
handler: async (client: CCExplorerClient) => {
return await client.getCurrentRound();
},
},
// === Governance ===
{
name: 'governance_get',
description: 'Get a governance vote by tracking CID',
inputSchema: z.object({
trackingCid: z.string().describe('The tracking CID of the governance vote'),
}),
handler: async (client: CCExplorerClient, args: { trackingCid: string }) => {
return await client.getGovernanceDetail(args.trackingCid);
},
},
{
name: 'governance_list',
description: 'List all governance votes (in progress and closed)',
inputSchema: z.object({}),
handler: async (client: CCExplorerClient) => {
return await client.getGovernance();
},
},
// === Overview ===
{
name: 'overview_get',
description: 'Get network overview including active validators, super validators, supply, consensus height, and open votes',
inputSchema: z.object({}),
handler: async (client: CCExplorerClient) => {
return await client.getOverview();
},
},
// === Parties ===
{
name: 'party_get',
description: 'Get details of a specific party (wallet) by ID',
inputSchema: z.object({
id: z.string().describe('The party ID'),
}),
handler: async (client: CCExplorerClient, args: { id: string }) => {
return await client.getPartyDetail(args.id);
},
},
// === Search ===
{
name: 'search',
description: 'Search for parties, updates, or other entities',
inputSchema: z.object({
query: z.string().describe('Search query string (party ID, update ID, etc.)'),
}),
handler: async (client: CCExplorerClient, args: { query: string }) => {
return await client.search(args.query);
},
},
// === Validators ===
{
name: 'super_validators_list',
description: 'List super validators and their reward weights',
inputSchema: z.object({}),
handler: async (client: CCExplorerClient) => {
return await client.getSuperValidators();
},
},
{
name: 'validators_list',
description: 'List all active validator licenses',
inputSchema: z.object({}),
handler: async (client: CCExplorerClient) => {
return await client.getValidators();
},
},
];
export type Tool = (typeof tools)[number];