@@ -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}
0 commit comments