Skip to content

Commit b4f1a29

Browse files
author
ci-bot
committed
add a tool for grabbing amp manifests
1 parent 4f68d47 commit b4f1a29

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed

libs/remix-ai-core/src/remix-mcp-server/handlers/AmpHandler.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,111 @@ export class AmpQueryHandler extends BaseToolHandler {
163163
}
164164
}
165165

166+
/**
167+
* Amp Dataset Manifest argument types
168+
*/
169+
export interface AmpDatasetManifestArgs {
170+
datasetName: string;
171+
version: string;
172+
}
173+
174+
/**
175+
* Amp Dataset Manifest result types
176+
*/
177+
export interface AmpDatasetManifestResult {
178+
success: boolean;
179+
manifest?: any;
180+
datasetName: string;
181+
version: string;
182+
error?: string;
183+
}
184+
185+
/**
186+
* Amp Dataset Manifest Tool Handler
187+
*/
188+
export class AmpDatasetManifestHandler extends BaseToolHandler {
189+
name = 'amp_dataset_manifest';
190+
description = 'Fetch manifest information for a specific Amp dataset version';
191+
inputSchema = {
192+
type: 'object',
193+
properties: {
194+
datasetName: {
195+
type: 'string',
196+
description: 'Dataset name in format owner/name (e.g., "shiyasmohd/counter")'
197+
},
198+
version: {
199+
type: 'string',
200+
description: 'Dataset version (e.g., "0.0.2")'
201+
}
202+
},
203+
required: ['datasetName', 'version']
204+
};
205+
206+
getPermissions(): string[] {
207+
return ['amp:dataset:manifest'];
208+
}
209+
210+
validate(args: AmpDatasetManifestArgs): boolean | string {
211+
const required = this.validateRequired(args, ['datasetName', 'version']);
212+
if (required !== true) return required;
213+
214+
const types = this.validateTypes(args, {
215+
datasetName: 'string',
216+
version: 'string'
217+
});
218+
if (types !== true) return types;
219+
220+
if (args.datasetName.trim().length === 0) {
221+
return 'Dataset name cannot be empty';
222+
}
223+
224+
if (args.version.trim().length === 0) {
225+
return 'Version cannot be empty';
226+
}
227+
228+
return true;
229+
}
230+
231+
async execute(args: AmpDatasetManifestArgs, plugin: Plugin): Promise<IMCPToolResult> {
232+
try {
233+
// Show a notification that the manifest is being fetched
234+
plugin.call('notification', 'toast', `Fetching manifest for ${args.datasetName}@${args.version}...`);
235+
236+
const url = `https://api.registry.amp.staging.thegraph.com/api/v1/datasets/${args.datasetName}/versions/${args.version}/manifest`;
237+
238+
const response = await fetch(url);
239+
240+
if (!response.ok) {
241+
throw new Error(`HTTP error! status: ${response.status}`);
242+
}
243+
244+
const manifest = await response.json();
245+
246+
const result: AmpDatasetManifestResult = {
247+
success: true,
248+
manifest: manifest,
249+
datasetName: args.datasetName,
250+
version: args.version
251+
};
252+
253+
// Show success notification
254+
plugin.call('notification', 'toast', `Manifest fetched successfully for ${args.datasetName}@${args.version}`);
255+
256+
return this.createSuccessResult(result);
257+
258+
} catch (error) {
259+
console.error('Amp dataset manifest fetch error:', error);
260+
261+
const errorMessage = error instanceof Error ? error.message : String(error);
262+
263+
// Show error notification
264+
plugin.call('notification', 'toast', `Failed to fetch manifest: ${errorMessage}`);
265+
266+
return this.createErrorResult(`Failed to fetch manifest: ${errorMessage}`);
267+
}
268+
}
269+
}
270+
166271
/**
167272
* Create Amp tool definitions
168273
*/
@@ -175,6 +280,14 @@ export function createAmpTools(): RemixToolDefinition[] {
175280
category: ToolCategory.ANALYSIS,
176281
permissions: ['amp:query'],
177282
handler: new AmpQueryHandler()
283+
},
284+
{
285+
name: 'amp_dataset_manifest',
286+
description: 'Fetch manifest information for a specific Amp dataset version',
287+
inputSchema: new AmpDatasetManifestHandler().inputSchema,
288+
category: ToolCategory.ANALYSIS,
289+
permissions: ['amp:dataset:manifest'],
290+
handler: new AmpDatasetManifestHandler()
178291
}
179292
];
180293
}

libs/remix-ai-core/src/remix-mcp-server/providers/AmpResourceProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ LIMIT 100;
285285
4. **Cast string values** to numeric types when doing math operations
286286
5. **Use fully qualified names** for tables to avoid ambiguity
287287
6. **Consider time ranges** when querying historical data
288+
7. **You can use the tool amp_dataset_manifest** to fetch dataset manifests programmatically. That will help you understand the schema and available tables.
288289
289290
## Common Gotchas
290291
@@ -302,7 +303,6 @@ AMP_QUERY_URL=https://gateway.amp.example.com
302303
AMP_QUERY_TOKEN=your-auth-token
303304
\`\`\`
304305
305-
If not specified, defaults to \`/amp\` for the base URL.
306306
`;
307307

308308
return this.createTextContent('amp://documentation', documentation);

0 commit comments

Comments
 (0)