Skip to main content
Glama
LostInBrittany

RAGmonsters Custom PostgreSQL MCP Server

getMonsterById

Retrieve detailed information about a specific monster using its unique ID on the RAGmonsters Custom PostgreSQL MCP Server, simplifying data access and enhancing query efficiency.

Instructions

Get detailed information about a specific monster by ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
monsterIdYesID of the monster to retrieve

Implementation Reference

  • The core handler function for the getMonsterById tool. It queries the database for monster details by ID, retrieves associated abilities, keywords, flaws, strengths, and weaknesses, formats them into a structured JSON response, and returns it in the expected MCP content format.
    export async function getMonsterById(params) {
      try {
        if (!dbPool) {
          throw new Error('Database pool not initialized. Call initialize() first.');
        }
        
        logger.info(`getMonsterById called with params: ${JSON.stringify(params)}`);
        
        const { monsterId } = params;
        
        if (!monsterId) {
          logger.error('Monster ID is required but was not provided');
          throw new Error('Monster ID is required');
        }
        
        logger.debug(`Fetching monster with ID: ${monsterId}`);
        // Get basic monster information
        const monsterQuery = `
          SELECT 
            m.*
          FROM 
            monsters m
          WHERE 
            m.monster_id = $1
        `;
        
        const monsters = await executeQuery(dbPool, monsterQuery, [monsterId]);
        
        if (monsters.length === 0) {
          throw new Error(`Monster with ID ${monsterId} not found`);
        }
        
        const monster = monsters[0];
        
        // Get monster's abilities and keywords
        const abilitiesQuery = `
          SELECT 
            k.keyword_name,
            k.rating,
            a.ability_name,
            a.mastery_value
          FROM 
            questworlds_stats qs
          JOIN 
            keywords k ON qs.stats_id = k.stats_id
          JOIN 
            abilities a ON k.keyword_id = a.keyword_id
          WHERE 
            qs.monster_id = $1
          ORDER BY 
            k.keyword_name, a.ability_name
        `;
        
        const abilities = await executeQuery(dbPool, abilitiesQuery, [monsterId]);
        
        // Get monster's flaws
        const flawsQuery = `
          SELECT 
            f.flaw_name,
            f.rating
          FROM 
            questworlds_stats qs
          JOIN 
            flaws f ON qs.stats_id = f.stats_id
          WHERE 
            qs.monster_id = $1
          ORDER BY 
            f.rating DESC
        `;
        
        const flaws = await executeQuery(dbPool, flawsQuery, [monsterId]);
        
        // Get monster's strengths (augments)
        const strengthsQuery = `
          SELECT 
            target_name,
            modifier
          FROM 
            augments
          WHERE 
            monster_id = $1
        `;
        
        const strengths = await executeQuery(dbPool, strengthsQuery, [monsterId]);
        
        // Get monster's weaknesses (hindrances)
        const weaknessesQuery = `
          SELECT 
            target_name,
            modifier
          FROM 
            hindrances
          WHERE 
            monster_id = $1
        `;
        
        const weaknesses = await executeQuery(dbPool, weaknessesQuery, [monsterId]);
        
        // Organize abilities by keyword
        const keywordAbilities = {};
        abilities.forEach(item => {
          if (!keywordAbilities[item.keyword_name]) {
            keywordAbilities[item.keyword_name] = {
              name: item.keyword_name,
              rating: item.rating,
              abilities: []
            };
          }
          
          keywordAbilities[item.keyword_name].abilities.push({
            name: item.ability_name,
            mastery: item.mastery_value
          });
        });
        
        // Format the response
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              id: monster.monster_id,
              name: monster.name,
              category: monster.category,
              habitat: monster.habitat,
              rarity: monster.rarity,
              discovery: monster.discovery,
              physicalAttributes: {
                height: monster.height,
                weight: monster.weight,
                appearance: monster.appearance
              },
              powers: {
                primary: monster.primary_power,
                secondary: monster.secondary_power,
                special: monster.special_ability
              },
              keywords: Object.values(keywordAbilities),
              flaws: flaws.map(flaw => ({
                name: flaw.flaw_name,
                rating: flaw.rating
              })),
              strengths: strengths.map(strength => ({
                target: strength.target_name,
                modifier: strength.modifier
              })),
              weaknesses: weaknesses.map(weakness => ({
                target: weakness.target_name,
                modifier: weakness.modifier
              }))
            })
          }]
        };
      } catch (error) {
        logger.error(`Error in getMonsterById: ${error.message}`);
        logger.error(error.stack);
        throw new Error(`Failed to retrieve monster details: ${error.message}`);
      }
    }
  • The registration of the getMonsterById tool with the MCP server using server.addTool(). Includes the tool name, description, input schema using Zod (requiring a numeric monsterId), and binds the execute function to the imported getMonsterById handler.
    server.addTool({
      name: 'getMonsterById',
      description: 'Get detailed information about a specific monster by ID',
      parameters: z.object({
        monsterId: z.number().describe('ID of the monster to retrieve')
      }),
      execute: getMonsterById
    });
  • Zod schema definition for the getMonsterById tool input parameters, specifying that monsterId must be a number.
    parameters: z.object({
      monsterId: z.number().describe('ID of the monster to retrieve')
    }),
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 the tool retrieves 'detailed information' but doesn't specify what that includes (e.g., stats, abilities, weaknesses), whether it's a read-only operation, error handling for invalid IDs, or performance characteristics like rate limits. This leaves significant gaps for agent understanding.

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 purpose without unnecessary words. It is front-loaded with the core action and resource, 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?

For a simple lookup tool with one parameter and no output schema, the description is minimally adequate. However, it lacks details on the returned data structure (e.g., what 'detailed information' entails) and behavioral aspects like error cases, which would help an agent use it correctly. The absence of annotations exacerbates these gaps.

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?

The schema description coverage is 100%, with the parameter 'monsterId' clearly documented as 'ID of the monster to retrieve'. The description adds no additional semantic context beyond what the schema provides, such as format examples or valid ranges. Given the high schema coverage, the baseline score of 3 is appropriate.

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 detailed information') and resource ('about a specific monster by ID'), making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'getMonsterByName' or 'getMonsterByHabitat', which also retrieve monster information but use different identifiers.

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 sibling tools like 'getMonsterByName' (for name-based lookup) or 'getMonsterByHabitat' (for habitat-based filtering), nor does it specify prerequisites such as needing a valid monster ID.

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