Skip to main content
Glama

jp_lit_search_kokusho_fulltext

Search Japanese book database transcription and OCR snippets by keyword. Retrieve bid, frame number, snippet, and official URL without fetching full texts or images.

Instructions

国書データベースの翻刻/OCR系スニペッ���をキーワード検索する。本文全体・manifest 本体・画像本体は取得せず、bid、コマ番号、スニペット、公式確認 URL を返す。国書DB Web アプリの公開 JSON endpoint に依存するため、採用時は公式画面で最終確認する

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes
limitNo
pageNo
force_refreshNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes
pageYes
limitYes
totalYes
itemsYes
rawYes
cacheNo

Implementation Reference

  • Main handler function `createJpLitSearchKokushoFulltextTool`. Parses input using searchKokushoFulltextInputSchema, calls `client.searchFulltext(parsed.keyword)` to fetch from the Kokusho API, maps the response with `mapKokushoFulltextResponse`, caches via `runCachedTool`, and returns structured JSON content with cache info.
    export function createJpLitSearchKokushoFulltextTool(
      client: KokushoClient,
      cache: FileCache = createFileCache(),
      sessions: SessionStore = createSessionStore()
    ) {
      return async (input: unknown) => {
        const parsed = searchKokushoFulltextInputSchema.parse(input);
        const { force_refresh, ...cacheableInput } = parsed;
    
        const result = await runCachedTool<SearchKokushoFulltextOutput>({
          tool: "jp_lit_search_kokusho_fulltext",
          input: cacheableInput,
          cache,
          sessions,
          bypassCache: force_refresh,
          live: async () => {
            try {
              const payload = await client.searchFulltext(parsed.keyword);
              const mapped = mapKokushoFulltextResponse(payload, parsed.page, parsed.limit);
              if (!mapped) {
                throw new NotFoundError("国書DB全文検索結果が取得できませんでした");
              }
    
              return searchKokushoFulltextOutputSchema.parse({
                keyword: parsed.keyword,
                page: parsed.page,
                limit: parsed.limit,
                total: mapped.total,
                items: mapped.items,
                raw: mapped.raw
              });
            } catch (error) {
              if (error instanceof NotFoundError) {
                throw error;
              }
              throw networkRestrictionError(error);
            }
          }
        });
    
        const structuredContent = addCacheInfo(result.structuredContent, result);
    
        return {
          content: [{ type: "text" as const, text: JSON.stringify(structuredContent, null, 2) }],
          structuredContent
        };
      };
    }
  • Helper `mapKokushoFulltextResponse` transforms the raw Kokusho API response into structured items with bid, title, authors, koma, line, snippet, viewer_url, source_metadata. Handles pagination via page/limit offset.
    export function mapKokushoFulltextResponse(payload: unknown, page: number, limit: number) {
      if (!Array.isArray(payload)) {
        return null;
      }
    
      const offset = (page - 1) * limit;
      const selected = payload.slice(offset, offset + limit);
      const items = selected.map((item) => {
        const record = item as Record<string, unknown>;
        const bid = readString(record.bid) ?? "missing-kokusho-id";
        const koma = readNumber(record.koma);
        const line = readNumber(record.line);
        const context = readString(record.context);
    
        return {
          bid,
          source_id: bid,
          title: readString(record.title),
          work_title: readString(record.wname),
          authors: readStringArray(record.authorlist).map((name) => ({ name, role: "author" })),
          koma,
          line,
          snippet: context ? snippetText(context) : null,
          viewer_url: buildViewerUrl(bid, koma),
          biblio_url: buildBiblioUrl(bid),
          source_metadata: {
            satsu: record.satsu ?? null,
            line,
            totalkoma: record.totalkoma ?? null,
            kansha: record.kansha ?? null,
            shubetsu: record.shubetsu ?? null,
            wkeyword: record.wkeyword ?? null,
            authorhead: record.authorhead ?? null
          }
        };
      });
    
      return {
        total: payload.length,
        items,
        raw: {
          endpoint: "fulltextSearch",
          upstream_total: payload.length,
          returned_count: items.length
        }
      };
    }
  • KokushoClient method `searchFulltext(keyword)` calls the Kokusho API endpoint `/api/fulltextSearch?keyword=...` and returns the raw JSON payload.
        async searchFulltext(keyword) {
          const url = new URL(withBase(baseUrl, "/api/fulltextSearch"));
          url.searchParams.set("keyword", keyword);
          return fetchJson<unknown>(url.toString());
        },
        async searchImageTags(keyword, page) {
          const url = new URL(withBase(baseUrl, "/api/tagSearch"));
          url.searchParams.set("searchkbn", "simple");
          url.searchParams.set("keyword", keyword);
          url.searchParams.set("page", String(page));
          return fetchJson<unknown>(url.toString());
        }
      };
    }
Behavior4/5

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

With no annotations provided, the description bears full transparency burden. It discloses that it does not retrieve full content, only snippet metadata, and depends on an external public JSON endpoint, advising final confirmation. It omits details like caching or rate limits, but the key behavioral traits are covered.

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

Conciseness5/5

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

Three sentences, front-loaded with purpose, followed by return information and a caveat. Every sentence adds value with no redundancy.

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

Completeness3/5

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

The description covers purpose, return values, and a limitation. However, it lacks parameter explanations and details about the output schema (though output schema exists in context). Given the tool's complexity and lack of annotations, more information is needed for full completeness.

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

Parameters2/5

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

Schema coverage is 0%, so the description must compensate. It does not describe the parameters (keyword, limit, page, force_refresh) beyond implying keyword is used. The return fields are listed, but parameter meanings, defaults, and constraints are absent, which is inadequate for a 4-parameter tool.

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

Purpose5/5

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

The description clearly states it searches for transcription/OCR snippets in the National Books Database, specifies what it returns (bid, frame number, snippet, URL) and what it does not retrieve (full text, manifest, image). It distinguishes from sibling tools like jp_lit_search_fulltext by explicitly excluding full-text retrieval.

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 advises final confirmation on the official screen due to external dependency, but it does not explicitly state when to use this tool versus alternatives. The intended use case is implied through the return types, but no direct guidance on prerequisites or exclusions is given.

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/itarunnn/jp-lit-mcp'

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