search_nodes
Retrieve specific node types like datasheets, forms, or folders from a workspace using filters such as permissions and search queries. Simplify node management in AITable MCP Server.
Instructions
Retrieve nodes based on specific types, permissions, and queries. Nodes in AITable can be of several types: datasheets (also known as sheets, or spreadsheets), form, dashboard, and folders.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| node_type | Yes | Filter the node list to only include nodes of the specified type. Common types include: "Datasheet", "Form", "Automation", "Folder", "Mirror" | |
| query | No | A search query to filter nodes by name. If not specified, all nodes will be returned. | |
| space_id | Yes | The ID of the workspace to fetch nodes from. |
Implementation Reference
- src/index.ts:89-129 (handler)The main handler function for the 'search_nodes' tool. It validates inputs, constructs the API URL using AITable service, fetches nodes from the API, transforms the node data by renaming 'id' to 'node_id', and returns formatted response or error.async ({ space_id, node_type, query }) => { try { // Validate the space_id if (!space_id || !node_type) { throw new Error("space_id and node_type are required."); } const queryStr = aitableService.buildQueryString({ type: node_type, query }); const url = `/v2/spaces/${space_id}/nodes${queryStr}`; const result: ResponseVO<{ nodes: NodeVO[] }> = await aitableService.fetchFromAPI(url, { method: "GET", }); if (!result.success) { throw new Error(result.message || "Failed to search nodes"); } const nodes: ToolNodeVO[] = []; result.data.nodes.forEach(node => { const { id, ...restNodeProps } = node; nodes.push({ ...restNodeProps, node_id: id, }) }) return formatToolResponse({ success: true, data: nodes }); } catch (error) { console.error("Error in search_nodes:", error); return formatToolResponse({ success: false, message: error instanceof Error ? error.message : "Unknown error occurred" }, true); } }
- src/index.ts:84-88 (schema)Zod schema defining the input parameters for the search_nodes tool: space_id (required), node_type (required), query (optional).{ space_id: z.string().describe('The ID of the workspace to fetch nodes from.'), node_type: z.string().describe('Filter the node list to only include nodes of the specified type. Common types include: "Datasheet", "Form", "Automation", "Folder", "Mirror"'), query: z.string().optional().describe('A search query to filter nodes by name. If not specified, all nodes will be returned.'), },
- src/index.ts:82-130 (registration)Registration of the search_nodes tool on the MCP server, specifying name, description, input schema, and handler function.server.tool("search_nodes", "Retrieve nodes based on specific types, permissions, and queries. Nodes in AITable can be of several types: datasheets (also known as sheets, or spreadsheets), form, dashboard, and folders.", { space_id: z.string().describe('The ID of the workspace to fetch nodes from.'), node_type: z.string().describe('Filter the node list to only include nodes of the specified type. Common types include: "Datasheet", "Form", "Automation", "Folder", "Mirror"'), query: z.string().optional().describe('A search query to filter nodes by name. If not specified, all nodes will be returned.'), }, async ({ space_id, node_type, query }) => { try { // Validate the space_id if (!space_id || !node_type) { throw new Error("space_id and node_type are required."); } const queryStr = aitableService.buildQueryString({ type: node_type, query }); const url = `/v2/spaces/${space_id}/nodes${queryStr}`; const result: ResponseVO<{ nodes: NodeVO[] }> = await aitableService.fetchFromAPI(url, { method: "GET", }); if (!result.success) { throw new Error(result.message || "Failed to search nodes"); } const nodes: ToolNodeVO[] = []; result.data.nodes.forEach(node => { const { id, ...restNodeProps } = node; nodes.push({ ...restNodeProps, node_id: id, }) }) return formatToolResponse({ success: true, data: nodes }); } catch (error) { console.error("Error in search_nodes:", error); return formatToolResponse({ success: false, message: error instanceof Error ? error.message : "Unknown error occurred" }, true); } } );