Skip to main content
Glama
johnreitano

MCP Datastore Server

by johnreitano

datastore_filter

Filter entities stored in Google Cloud Datastore by exact field matches. Specify kind, field, and value to retrieve filtered results efficiently.

Instructions

Query entities with a simple equality filter on any field

Input Schema

NameRequiredDescriptionDefault
fieldYesThe field name to filter on (can be key field or property)
kindYesThe entity kind to query
limitNoMaximum number of results to return (default: 100)
valueYesThe value to match exactly

Input Schema (JSON Schema)

{ "properties": { "field": { "description": "The field name to filter on (can be key field or property)", "type": "string" }, "kind": { "description": "The entity kind to query", "type": "string" }, "limit": { "description": "Maximum number of results to return (default: 100)", "type": "number" }, "value": { "description": "The value to match exactly", "type": "string" } }, "required": [ "kind", "field", "value" ], "type": "object" }

Implementation Reference

  • Core implementation of the datastore_filter tool: creates a Google Cloud Datastore query filtered by the specified field and value, applies limit, and maps results to include keys.
    async filterEntities(kind: string, field: string, value: string, limit = 100): Promise<any[]> { try { let query = this.datastore.createQuery(kind); if (field === '__key__' || field === 'key') { const keyValue = isNaN(Number(value)) ? value : parseInt(value); const entityKey = this.datastore.key([kind, keyValue]); query = query.filter('__key__', '=', entityKey); } else { const convertedValue = this.convertValue(value); query = query.filter(field, '=', convertedValue); } query = query.limit(limit); const [entities] = await this.datastore.runQuery(query); return entities.map(entity => ({ key: entity[this.datastore.KEY], ...entity, })); } catch (error) { throw new Error(`Failed to filter entities: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • Input schema definition for the datastore_filter tool, including parameters kind, field, value (required), and optional limit.
    { name: 'datastore_filter', description: 'Query entities with a simple equality filter on any field', inputSchema: { type: 'object', properties: { kind: { type: 'string', description: 'The entity kind to query', }, field: { type: 'string', description: 'The field name to filter on (can be key field or property)', }, value: { type: 'string', description: 'The value to match exactly', }, limit: { type: 'number', description: 'Maximum number of results to return (default: 100)', }, }, required: ['kind', 'field', 'value'], }, },
  • Handler case in the CallToolRequestHandler that invokes the DatastoreClient.filterEntities method and formats the response as text content.
    case 'datastore_filter': const filteredResults = await datastoreClient.filterEntities( args.kind as string, args.field as string, args.value as string, args.limit as number | undefined ); return { content: [ { type: 'text', text: JSON.stringify(filteredResults, null, 2), }, ], };
  • Helper method used in filterEntities to convert string input value to appropriate type (boolean, number, null, or string) for Datastore filter.
    private convertValue(value: string): any { if (value.toLowerCase() === 'true') return true; if (value.toLowerCase() === 'false') return false; if (value.toLowerCase() === 'null') return null; const numValue = Number(value); if (!isNaN(numValue)) return numValue; return value; } }

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/johnreitano/daisy'

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