ad4m_get_neighbourhood
Get a shared AD4M Neighbourhood using its Perspective UUID.
Instructions
Read a shared AD4M Neighbourhood by Perspective UUID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uuid | Yes | Perspective UUID |
Implementation Reference
- index.js:350-360 (handler)The getNeighbourhood function that executes the tool logic. It calls the AD4M GraphQL API to query a perspective by UUID and returns the perspective data including uuid, name, sharedUrl, and neighbourhood info.
async function getNeighbourhood({ uuid }) { const data = await gql( `query Perspective($uuid: String!) { perspective(uuid: $uuid) { uuid name sharedUrl neighbourhood { author timestamp } } }`, { uuid } ); return ok(data.perspective); } - index.js:666-666 (handler)The case statement that dispatches to getNeighbourhood in the built index.js (switch-based handler dispatch).
case "ad4m_get_neighbourhood": return { content: await getNeighbourhood(args) }; - index.js:564-573 (registration)Tool registration in the built index.js (ListToolsRequestSchema response), declaring the tool name, description, and input schema with required uuid parameter.
{ name: "ad4m_get_neighbourhood", description: "Read a shared AD4M Neighbourhood by URL. Use to inspect semantic graphs shared with other agents or communities.", inputSchema: { type: "object", properties: { uuid: { type: "string", description: "Perspective UUID" }, }, required: ["uuid"], }, - src/index.ts:352-367 (schema)TypeScript source registration of the tool using server.tool(), with input validation via zod schema (uuid as string) and the handler that queries the GraphQL perspective endpoint.
// 6. ad4m_get_neighbourhood server.tool("ad4m_get_neighbourhood", "Read a shared AD4M Neighbourhood by Perspective UUID.", { uuid: z.string().describe("Perspective UUID") }, async ({ uuid }) => { const data = await gql( `query Q($uuid: String!) { perspective(uuid: $uuid) { uuid name sharedUrl neighbourhood { author timestamp } } }`, { uuid } ); return ok(data.perspective); } ); - index.js:162-163 (helper)The 'ok' helper function used by getNeighbourhood to format the response as a text content item.
function ok(data) { return [{ type: "text", text: JSON.stringify(data, null, 2) }]; } function err(e) { return [{ type: "text", text: JSON.stringify({ error: String(e) }) }]; }