Skip to main content
Glama

documents-get-by-id

Retrieve a document in markdown format using its unique ID from the Shortcut project management system.

Instructions

Get a document as markdown by its ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
docIdYesThe ID of the document to retrieve

Implementation Reference

  • The handler function for the 'documents-get-by-id' tool. It retrieves the document by ID using the Shortcut client and returns a formatted result or error.
    private async getDocumentById(docId: string) { try { const doc = await this.client.getDocById(docId); if (!doc) return this.toResult(`Document with ID ${docId} not found.`); return this.toResult(`Document with ID ${docId}`, doc); } catch (error) { const errorMessage = error instanceof Error ? error.message : "Unknown error"; return this.toResult(`Failed to get document: ${errorMessage}`); } }
  • Input schema validation using Zod for the document ID parameter.
    { docId: z.string().describe("The ID of the document to retrieve"), },
  • Registration of the 'documents-get-by-id' tool on the MCP server, including description, input schema, and handler binding.
    server.addToolWithReadAccess( "documents-get-by-id", "Get a document as markdown by its ID", { docId: z.string().describe("The ID of the document to retrieve"), }, async ({ docId }: { docId: string }) => await tools.getDocumentById(docId), );
  • Helper method used by the handler to format the tool response as MCP CallToolResult with JSON data embedded in text.
    protected toResult( message: string, data?: unknown, paginationToken?: string | null | undefined, ): CallToolResult { return { content: [ { type: "text", text: `${message}${data !== undefined ? `\n\n<json>\n${JSON.stringify(data, null, 2)}\n</json>${paginationToken ? `\n\n<next-page-token>${paginationToken}</next-page-token>` : ""}` : ""}`, }, ], }; }

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/useshortcut/mcp-server-shortcut'

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