Skip to main content
Glama

get-document-by-id

Retrieve complete content of BaaS authentication system documents using document ID. Supports optional metadata inclusion for comprehensive document access.

Instructions

문서 ID로 특정 BaaS 인증 시스템 문서의 전체 내용을 조회합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes조회할 문서의 ID (search-documents 결과에서 확인 가능)
includeMetadataNo문서 메타데이터 포함 여부 (기본값: false)

Implementation Reference

  • Factory function that creates the tool object with the handler for 'get-document-by-id'. The handler fetches the document by ID from the repository, replaces project ID placeholders, adds metadata if requested, suggests similar documents, and returns formatted text content.
    export function createGetDocumentByIdTool(repository: BaaSDocsRepository, projectId?: string | null) {
      return {
        handler: async (params: GetDocumentByIdParams): Promise<CallToolResult> => {
          try {
            const { id, includeMetadata = false } = params;
            
            const document = repository.getDocumentById(id);
            
            if (!document) {
              return {
                content: [
                  {
                    type: "text",
                    text: `ID ${id}에 해당하는 문서를 찾을 수 없습니다. search-documents를 사용하여 먼저 문서를 검색해보세요.`
                  }
                ]
              };
            }
    
            let responseText = `# ${document.getTitle()}\n\n`;
            
            if (includeMetadata) {
              responseText += `**문서 정보**:\n`;
              responseText += `- ID: ${document.getId()}\n`;
              responseText += `- URL: ${document.getUrl()}\n`;
              responseText += `- 설명: ${document.getDescription()}\n`;
              responseText += `- 키워드: ${Array.from(document.getKeywords()).slice(0, 10).join(', ')}\n\n`;
              responseText += `---\n\n`;
            }
            
            let contentText = document.getContent();
    
            // Project ID 플레이스홀더 교체
            if (projectId) {
              // [PROJECT_ID] 플레이스홀더를 실제 값으로 교체
              contentText = contentText.replace(/\[PROJECT_ID\]/g, projectId);
              
              // 문서 상단에 설정 정보 추가
              responseText += `> 📌 **현재 Project ID**: \`${projectId}\`\n> 아래 코드에서 [PROJECT_ID]가 자동으로 교체되었습니다.\n\n`;
            } else {
              // Project ID가 설정되지 않은 경우 안내
              responseText += `> ⚠️ **Project ID 미설정**: Claude Desktop 설정에서 --project-id를 추가하세요.\n> 아래 코드의 [PROJECT_ID]를 실제 값으로 교체해야 합니다.\n\n`;
            }
    
            responseText += contentText;
    
            // Suggest similar documents
            const similarDocs = repository.getSimilarDocuments(document, 3);
            if (similarDocs.length > 0) {
              responseText += `\n\n## 관련 문서\n\n`;
              similarDocs.forEach((similarDoc, index) => {
                responseText += `${index + 1}. **${similarDoc.getTitle()}** (ID: ${similarDoc.getId()})\n`;
                responseText += `   - ${similarDoc.getDescription()}\n`;
                responseText += `   - ${similarDoc.getUrl()}\n\n`;
              });
            }
    
            return {
              content: [
                {
                  type: "text",
                  text: responseText
                }
              ]
            };
          } catch (error) {
            return {
              content: [
                {
                  type: "text",
                  text: `문서 조회 중 오류가 발생했습니다: ${error instanceof Error ? error.message : String(error)}`
                }
              ],
              isError: true
            };
          }
        }
      };
    }
  • Zod schema defining input parameters for the get-document-by-id tool: required 'id' (number) and optional 'includeMetadata' (boolean).
    export const GetDocumentByIdSchema = {
      id: z
        .number()
        .int()
        .describe("조회할 문서의 ID (search-documents 결과에서 확인 가능)"),
      includeMetadata: z
        .boolean()
        .default(false)
        .optional()
        .describe("문서 메타데이터 포함 여부 (기본값: false)")
    };
  • src/server.ts:78-90 (registration)
    Registers the 'get-document-by-id' tool on the MCP server using server.tool(), providing name, description, input schema, and the handler function.
      server.tool(
        "get-document-by-id",
        `문서 ID로 특정 BaaS 인증 시스템 문서의 전체 내용을 조회합니다.
    
    ⚠️ **중요**: 이 문서만으로 구현하지 말고, \`get-project-config\`에서 제공하는 필수 구현 규칙을 함께 적용해야 합니다.
    
    📌 **필수 참조 사항**:
    - 보안 설정: credentials, HttpOnly 쿠키
    - 에러 처리: ServiceException 표준 형식
    - 상태 관리: 조건부 렌더링 패턴`,
        GetDocumentByIdSchema,
        getDocumentByIdTool.handler
      );
  • Core repository method used by the tool handler to retrieve a BaaSDocument by its numeric ID from both feature and common documents.
    getDocumentById(id: number): BaaSDocument | undefined {
      // Feature와 common 문서 모두에서 검색
      const allDocs = [...this.featureDocs, ...this.commonDocs];
      return allDocs.find(doc => doc.getId() === id);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states it's a retrieval operation. It doesn't disclose behavioral traits like authentication requirements, rate limits, error conditions, response format, or whether it's idempotent. For a read operation with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence that efficiently conveys the core purpose without unnecessary words. However, it could be slightly more front-loaded by mentioning the system context earlier, but overall it's appropriately concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a tool that retrieves document content. It doesn't explain what 'entire content' means, what format it returns, or any behavioral constraints. The context signals show moderate complexity (2 parameters), but the description doesn't adequately address the gaps left by missing structured data.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description doesn't add any parameter meaning beyond what's in the schema (e.g., it doesn't explain what 'entire content' includes versus metadata). Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('retrieve entire content') and resource ('specific BaaS authentication system document'), with the qualifier 'by document ID' providing specificity. It distinguishes from 'search-documents' by focusing on single-document retrieval rather than searching, though it doesn't explicitly differentiate from 'get-project-config'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when you have a specific document ID (referencing 'search-documents' for obtaining IDs), but doesn't explicitly state when to use this tool versus 'get-project-config' or provide any exclusion criteria. The guidance is partial but not comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/mbaas-inc/BaaS-MCP'

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