Skip to main content
Glama
LostInBrittany

RAGmonsters Custom PostgreSQL MCP Server

getHabitats

Retrieve a comprehensive list of all available habitats stored in the RAGmonsters dataset, ensuring efficient access to monster habitat data via an optimized API.

Instructions

Get a list of all available habitats in the database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the getHabitats tool. It queries the database for distinct non-null habitats from the monsters table, extracts the habitat names, logs the action, and returns them as a JSON string in the expected MCP content format.
    export async function getHabitats() {
      try {
        if (!dbPool) {
          throw new Error('Database pool not initialized. Call initialize() first.');
        }
        
        logger.info('getHabitats called');
        
        // Query to get distinct habitats
        const query = `
          SELECT DISTINCT habitat
          FROM monsters
          WHERE habitat IS NOT NULL
          ORDER BY habitat ASC
        `;
        
        const results = await executeQuery(dbPool, query);
        
        // Extract habitat names
        const habitats = results.map(row => row.habitat);
        
        logger.info(`getHabitats returning ${habitats.length} habitats`);
        
        // Format the response
        return {
          content: [{
            type: 'text',
            text: JSON.stringify(habitats)
          }]
        };
      } catch (error) {
        logger.error(`Error in getHabitats: ${error.message}`);
        logger.error(error.stack);
        throw new Error(`Failed to retrieve habitats: ${error.message}`);
      }
    }
  • The registration of the getHabitats tool with the MCP server. It defines the tool name, description, empty parameters schema (since no inputs), and links the execute function to the imported getHabitats handler.
    server.addTool({
      name: 'getHabitats',
      description: 'Get a list of all available habitats in the database',
      parameters: z.object({}),
      execute: getHabitats
    });
  • The Zod schema for the getHabitats tool parameters, which is an empty object indicating no input parameters are required.
    parameters: z.object({}),
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states it retrieves a list but doesn't specify if it's read-only, safe, paginated, or has any side effects. For a tool with zero annotation coverage, this is a significant gap in transparency.

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?

The description is a single, efficient sentence that directly states the tool's function without any fluff. It's appropriately sized and front-loaded, making it easy to parse quickly.

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?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimally adequate. However, it lacks details on behavioral aspects like safety or output format, which would be helpful for an agent to use it correctly, especially without annotations.

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

Parameters4/5

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

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add param info, which is fine here, but it could hint at any implicit constraints (e.g., sorting or limits), though not required. Baseline is high due to no parameters.

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 verb ('Get') and resource ('list of all available habitats'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'getMonsterByHabitat' or 'getMonsters', which also retrieve data but with different scopes or filters, so it lacks sibling distinction.

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 alternatives. It doesn't mention scenarios where this tool is preferred over siblings like 'getMonsterByHabitat' (which filters by habitat) or 'getMonsters' (which retrieves monsters instead of habitats), leaving the agent without usage context.

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

Related 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/LostInBrittany/RAGmonsters-mcp-pg'

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