Skip to main content
Glama
tables.tools.ts3.34 kB
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; import { getClient } from '../utils/client-manager.js'; import { TablesClient } from '../client/tables.js'; import { prefixToolName } from '../utils/tool-naming.js'; /** * Register Tables tools with the MCP server * @param server MCP server instance */ export function registerTablesTools(server: McpServer) { server.tool( prefixToolName('tables_list_tables'), 'List all tables in Nextcloud Tables', {}, async () => { const tables = await getClient(TablesClient).listTables(); return { content: [ { type: 'text', text: JSON.stringify(tables, null, 2), }, ], }; } ); server.tool( prefixToolName('tables_get_schema'), 'Get schema of a specific table', { tableId: z.string().describe('The ID of the table'), }, async ({ tableId }) => { const table = await getClient(TablesClient).getTable(tableId); return { content: [ { type: 'text', text: JSON.stringify(table, null, 2), }, ], }; } ); server.tool( prefixToolName('tables_read_table'), 'Read data from a table', { tableId: z.string().describe('The ID of the table'), }, async ({ tableId }) => { const rows = await getClient(TablesClient).readTable(tableId); return { content: [ { type: 'text', text: JSON.stringify(rows, null, 2), }, ], }; } ); server.tool( prefixToolName('tables_insert_row'), 'Insert a new row into a table', { tableId: z.string().describe('The ID of the table'), row: z.record(z.any()).describe('Row data as key-value pairs'), }, async ({ tableId, row }) => { const result = await getClient(TablesClient).insertRow(tableId, row); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); server.tool( prefixToolName('tables_update_row'), 'Update an existing row in a table', { tableId: z.string().describe('The ID of the table'), rowId: z.string().describe('The ID of the row'), row: z.record(z.any()).describe('Updated row data as key-value pairs'), }, async ({ tableId, rowId, row }) => { const result = await getClient(TablesClient).updateRow(tableId, rowId, row); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } ); server.tool( prefixToolName('tables_delete_row'), 'Delete a row from a table', { tableId: z.string().describe('The ID of the table'), rowId: z.string().describe('The ID of the row to delete'), }, async ({ tableId, rowId }) => { await getClient(TablesClient).deleteRow(tableId, rowId); return { content: [ { type: 'text', text: JSON.stringify({ status_code: 200, message: `Row ${rowId} deleted successfully from table ${tableId}`, }, null, 2), }, ], }; } ); }

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/hithereiamaliff/mcp-nextcloud'

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