Skip to main content
Glama

search_law

Search Japanese labor and social insurance laws by keyword using the e-Gov API. Find relevant legal texts when you don't know the specific law name.

Instructions

労働・社会保険関連の法令をキーワードで検索する。法令名が分からない場合に使用。e-Gov法令API v2を使用。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes検索キーワード。例: "労働基準", "雇用保険", "安全衛生", "育児休業", "厚生年金"
law_typeNo法令種別で絞り込み。Act=法律, CabinetOrder=政令(施行令), MinisterialOrdinance=省令(施行規則)
limitNo取得件数(デフォルト10、最大20)

Implementation Reference

  • The handler function in search_law.ts executes the searchLaw logic and formats the tool response.
    async (args) => {
      try {
        const result = await searchLaw({
          keyword: args.keyword,
          lawType: args.law_type,
          limit: args.limit,
        });
    
        if (result.results.length === 0) {
          return {
            content: [{
              type: 'text' as const,
              text: `"${args.keyword}" に一致する法令が見つかりませんでした。\nキーワードを変えて再検索してください(例: 類義語や略称を試す)。\nまた、get_law で法令名を直接指定して条文を取得することもできます。`,
            }],
          };
        }
    
        const lines = result.results.map((r, i) =>
          `${i + 1}. **${r.lawTitle}**\n   法令番号: ${r.lawNum}\n   law_id: ${r.lawId}\n   種別: ${r.lawType}\n   URL: ${r.egovUrl}`
        );
    
        return {
          content: [{
            type: 'text' as const,
            text: `# 法令検索結果: "${args.keyword}"\n\n${lines.join('\n\n')}\n\n---\n出典:e-Gov法令検索(デジタル庁)`,
          }],
        };
      } catch (error) {
        return {
          content: [{
            type: 'text' as const,
            text: `エラー: ${error instanceof Error ? error.message : String(error)}`,
          }],
          isError: true,
        };
      }
    }
  • The tool 'search_law' is registered here using the server.tool method.
    export function registerSearchLawTool(server: McpServer) {
      server.tool(
        'search_law',
        '労働・社会保険関連の法令をキーワードで検索する。法令名が分からない場合に使用。e-Gov法令API v2を使用。',
        {
          keyword: z.string().describe(
            '検索キーワード。例: "労働基準", "雇用保険", "安全衛生", "育児休業", "厚生年金"'
          ),
          law_type: z.enum(['Act', 'CabinetOrder', 'MinisterialOrdinance']).optional().describe(
            '法令種別で絞り込み。Act=法律, CabinetOrder=政令(施行令), MinisterialOrdinance=省令(施行規則)'
          ),
          limit: z.number().optional().describe(
            '取得件数(デフォルト10、最大20)'
          ),
        },
        async (args) => {
          try {
            const result = await searchLaw({
              keyword: args.keyword,
              lawType: args.law_type,
              limit: args.limit,
            });
    
            if (result.results.length === 0) {
              return {
                content: [{
                  type: 'text' as const,
                  text: `"${args.keyword}" に一致する法令が見つかりませんでした。\nキーワードを変えて再検索してください(例: 類義語や略称を試す)。\nまた、get_law で法令名を直接指定して条文を取得することもできます。`,
                }],
              };
            }
    
            const lines = result.results.map((r, i) =>
              `${i + 1}. **${r.lawTitle}**\n   法令番号: ${r.lawNum}\n   law_id: ${r.lawId}\n   種別: ${r.lawType}\n   URL: ${r.egovUrl}`
            );
    
            return {
              content: [{
                type: 'text' as const,
                text: `# 法令検索結果: "${args.keyword}"\n\n${lines.join('\n\n')}\n\n---\n出典:e-Gov法令検索(デジタル庁)`,
              }],
            };
          } catch (error) {
            return {
              content: [{
                type: 'text' as const,
                text: `エラー: ${error instanceof Error ? error.message : String(error)}`,
              }],
              isError: true,
            };
          }
        }
      );
    }
  • The actual business logic 'searchLaw' that interacts with the e-Gov API is defined here.
    export async function searchLaw(params: {
      keyword: string;
      lawType?: string;
      limit?: number;
    }): Promise<SearchLawResult> {
      const limit = Math.min(params.limit ?? 10, 20);
      const results = await searchLaws(params.keyword, limit, params.lawType);
    
      return {
        keyword: params.keyword,
        results: results.map((r: EgovLawSearchResult) => ({
          lawTitle: r.revision_info?.law_title ?? r.current_revision_info?.law_title ?? '',
          lawId: r.law_info.law_id,
          lawNum: r.law_info.law_num,
          lawType: r.law_info.law_type,
          egovUrl: getEgovUrl(r.law_info.law_id),
        })),
      };
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the API source ('e-Gov法令API v2') which adds implementation context, but doesn't disclose important behavioral traits like rate limits, authentication requirements, error handling, or what the response format looks like (especially critical since there's no output schema). For a search tool with no annotation coverage, this is inadequate.

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?

The description is concise (two sentences) and front-loaded with the core purpose. The second sentence adds useful context about when to use it and the API source. Every sentence earns its place, though it could be slightly more structured.

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. It doesn't explain what the tool returns (format, structure, fields), error conditions, or important behavioral constraints. For a search tool that likely returns complex legal data, this leaves significant gaps for an AI agent to understand how to properly interpret results.

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 documents all parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema (keyword usage context is implied but not detailed). With high schema coverage, the baseline score of 3 is appropriate - the description doesn't compensate but doesn't need to.

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 tool's purpose: '労働・社会保険関連の法令をキーワードで検索する' (search labor and social insurance laws by keyword). It specifies the resource (laws) and action (search), but doesn't explicitly differentiate from sibling tools like 'get_law' or other search tools. The mention of 'e-Gov法令API v2' adds technical context but not sibling differentiation.

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 provides some usage context: '法令名が分からない場合に使用' (use when you don't know the law name). This implies when to use it (keyword-based search rather than known-name lookup), but doesn't explicitly mention when NOT to use it or name specific alternatives among the sibling tools. The guidance is helpful but incomplete.

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/kentaroajisaka/labor-law-mcp'

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