Skip to main content
Glama
johnreitano

MCP Datastore Server

by johnreitano

datastore_get

Retrieve a specific entity from Google Cloud Datastore using its key and kind, with optional parent key for hierarchical data structures.

Instructions

Get an entity by its key

Input Schema

NameRequiredDescriptionDefault
keyYesThe entity key (name or ID)
kindYesThe entity kind
parentNoParent key if the entity has a parent (optional)

Input Schema (JSON Schema)

{ "properties": { "key": { "description": "The entity key (name or ID)", "type": "string" }, "kind": { "description": "The entity kind", "type": "string" }, "parent": { "description": "Parent key if the entity has a parent (optional)", "type": "string" } }, "required": [ "kind", "key" ], "type": "object" }

Implementation Reference

  • Core implementation of the datastore_get tool logic: retrieves an entity from Google Cloud Datastore by constructing the key (handling numeric/ID or string name, optional parent) and fetching it.
    async getEntity(kind: string, key: string, parent?: string): Promise<any> { try { let entityKey; const keyValue = isNaN(Number(key)) ? key : parseInt(key); if (parent) { const parentKeyValue = isNaN(Number(parent)) ? parent : parseInt(parent); entityKey = this.datastore.key([kind, parentKeyValue, kind, keyValue]); } else { entityKey = this.datastore.key([kind, keyValue]); } const [entity] = await this.datastore.get(entityKey); if (!entity) { return null; } return { key: entity[this.datastore.KEY], ...entity, }; } catch (error) { throw new Error(`Failed to get entity: ${error instanceof Error ? error.message : 'Unknown error'}`); } }
  • Input schema for the datastore_get tool defining required 'kind' and 'key' parameters, optional 'parent'.
    inputSchema: { type: 'object', properties: { kind: { type: 'string', description: 'The entity kind', }, key: { type: 'string', description: 'The entity key (name or ID)', }, parent: { type: 'string', description: 'Parent key if the entity has a parent (optional)', }, }, required: ['kind', 'key'], },
  • src/index.ts:36-57 (registration)
    Registration of the datastore_get tool in the MCP listTools response.
    { name: 'datastore_get', description: 'Get an entity by its key', inputSchema: { type: 'object', properties: { kind: { type: 'string', description: 'The entity kind', }, key: { type: 'string', description: 'The entity key (name or ID)', }, parent: { type: 'string', description: 'Parent key if the entity has a parent (optional)', }, }, required: ['kind', 'key'], }, },
  • MCP callTool handler case for datastore_get: calls DatastoreClient.getEntity and returns text response with JSON or not found message.
    case 'datastore_get': const entity = await datastoreClient.getEntity( args.kind as string, args.key as string, args.parent as string | undefined ); return { content: [ { type: 'text', text: entity ? JSON.stringify(entity, null, 2) : 'Entity not found', }, ], };

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