Skip to main content
Glama

search_law

Search Japanese laws and regulations by name, number, or keywords using the e-Gov Law API to find legal information and track revisions.

Instructions

法令名や法令番号で法令を検索します。キーワード検索に対応しています。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordYes検索キーワード(法令名の一部や法令番号)
categoryNo法令の種別(1:法律、2:政令、3:省令など)
limitNo取得する最大件数(デフォルト: 100)

Implementation Reference

  • The main handler function for the 'search_law' tool. It destructures arguments (keyword, category, limit), builds the e-Gov API search URL, fetches the data, truncates if too long, and returns a formatted text response.
    async searchLaw(args) {
      const { keyword, category, limit = 100 } = args;
      
      // 検索APIのURL構築
      const params = new URLSearchParams();
      params.append('keyword', keyword);
      if (category) {
        params.append('category', category);
      }
      
      const url = `${EGOV_API_BASE}/lawlists/1?${params.toString()}`;
      
      try {
        const response = await fetch(url);
        if (!response.ok) {
          throw new Error(`API request failed: ${response.status}`);
        }
        
        const data = await response.text();
        
        return {
          content: [
            {
              type: 'text',
              text: `法令検索結果(キーワード: "${keyword}"):\n\n${data.substring(0, 5000)}${data.length > 5000 ? '\n...(省略)' : ''}`,
            },
          ],
        };
      } catch (error) {
        throw new Error(`法令検索に失敗しました: ${error.message}`);
      }
    }
  • Input schema/JSON Schema for the 'search_law' tool defining properties: keyword (string, required), category (string enum), limit (number, default 100).
    inputSchema: {
      type: 'object',
      properties: {
        keyword: {
          type: 'string',
          description: '検索キーワード(法令名の一部や法令番号)',
        },
        category: {
          type: 'string',
          description: '法令の種別(1:法律、2:政令、3:省令など)',
          enum: ['1', '2', '3', '4', '5'],
        },
        limit: {
          type: 'number',
          description: '取得する最大件数(デフォルト: 100)',
          default: 100,
        },
      },
      required: ['keyword'],
    },
  • index.js:47-70 (registration)
    Tool registration in the ListToolsRequestSchema response: defines name 'search_law', description, and inputSchema.
    {
      name: 'search_law',
      description: '法令名や法令番号で法令を検索します。キーワード検索に対応しています。',
      inputSchema: {
        type: 'object',
        properties: {
          keyword: {
            type: 'string',
            description: '検索キーワード(法令名の一部や法令番号)',
          },
          category: {
            type: 'string',
            description: '法令の種別(1:法律、2:政令、3:省令など)',
            enum: ['1', '2', '3', '4', '5'],
          },
          limit: {
            type: 'number',
            description: '取得する最大件数(デフォルト: 100)',
            default: 100,
          },
        },
        required: ['keyword'],
      },
    },
  • index.js:108-109 (registration)
    Dispatch/registration in the CallToolRequestSchema switch statement: routes 'search_law' calls to the searchLaw handler.
    case 'search_law':
      return await this.searchLaw(args);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions keyword search functionality but doesn't describe important behaviors like pagination (only implies limit via parameter), error handling, authentication requirements, rate limits, or what the search results look like. For a search tool 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?

The description is appropriately concise with just two sentences that directly state the tool's function. It's front-loaded with the core purpose and follows with additional capability. No wasted words, 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?

For a search tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the search returns, how results are structured, whether there's pagination beyond the limit parameter, or any behavioral constraints. The description should provide more context given the lack of structured metadata.

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 three parameters thoroughly. The description mentions keyword search but doesn't add meaningful semantic context beyond what's in the schema descriptions. The baseline of 3 is appropriate when the 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 tool's purpose: searching for laws/regulations by name or number using keyword search. It specifies the resource (laws/regulations) and action (search), but doesn't explicitly differentiate from sibling tools like 'get_law_data' or 'get_law_revision' which likely retrieve specific laws rather than search broadly.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus the sibling tools 'get_law_data' or 'get_law_revision'. It mentions keyword search capability but doesn't specify scenarios where this is preferable to direct retrieval or other alternatives.

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/groundcobra009/hourei-mcp-server'

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