Skip to main content
Glama
melaodoidao

Data.gov MCP Server

by melaodoidao

package_search

Search for government datasets on Data.gov using customizable queries, filters, and sorting options to find relevant packages efficiently.

Instructions

Search for packages (datasets) on Data.gov

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qNoSearch query
rowsNoNumber of results per page
sortNoSort order (e.g., "score desc, name asc")
startNoStarting offset for results

Implementation Reference

  • The core handler function that executes the package_search tool. It makes an HTTP GET request to the Data.gov API endpoint '/action/package_search' with the provided arguments and returns the response as formatted JSON text.
    private async packageSearch(args: PackageSearchArgs) { try { const response = await this.axiosInstance.get('/action/package_search', { params: args, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2) }, ], }; } catch (error) { return this.handleAxiosError(error); } }
  • The JSON schema defining the input parameters for the package_search tool, used in tool listing and validation.
    inputSchema: { type: 'object', properties: { q: { type: 'string', description: 'Search query' }, sort: { type: 'string', description: 'Sort order (e.g., "score desc, name asc")', }, rows: { type: 'number', description: 'Number of results per page', }, start: { type: 'number', description: 'Starting offset for results', }, },
  • src/index.ts:198-219 (registration)
    The tool registration metadata in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: 'package_search', description: 'Search for packages (datasets) on Data.gov', inputSchema: { type: 'object', properties: { q: { type: 'string', description: 'Search query' }, sort: { type: 'string', description: 'Sort order (e.g., "score desc, name asc")', }, rows: { type: 'number', description: 'Number of results per page', }, start: { type: 'number', description: 'Starting offset for results', }, }, }, },
  • src/index.ts:263-270 (registration)
    The dispatch case in the CallToolRequestSchema handler that validates arguments and invokes the packageSearch handler.
    case 'package_search': if (!isValidPackageSearchArgs(request.params.arguments)) { throw new McpError( ErrorCode.InvalidParams, 'Invalid package_search arguments' ); } return this.packageSearch(request.params.arguments);
  • TypeScript interface defining the expected arguments for the package_search tool.
    interface PackageSearchArgs { q?: string; sort?: string; rows?: number; start?: number; }
  • Helper function to validate if arguments match the PackageSearchArgs type before calling the handler.
    const isValidPackageSearchArgs = (args: any): args is PackageSearchArgs => typeof args === 'object' && args !== null && (args.q === undefined || typeof args.q === 'string') && (args.sort === undefined || typeof args.sort === 'string') && (args.rows === undefined || typeof args.rows === 'number') && (args.start === undefined || typeof args.start === 'number');

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/melaodoidao/datagov-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server