Skip to main content
Glama
Augmented-Nature

Reactome MCP Server

get_pathway_hierarchy

Retrieve hierarchical structure and parent-child relationships for Reactome pathways to understand biological pathway organization.

Instructions

Get hierarchical structure and parent/child relationships for a pathway

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesReactome pathway stable identifier

Implementation Reference

  • The handler function that implements the core logic for the get_pathway_hierarchy tool. It validates input, resolves the pathway ID, fetches pathway data from Reactome API, attempts to retrieve ancestor and child pathways, and returns formatted hierarchy information as JSON.
    private async handleGetPathwayHierarchy(args: any) {
      if (!isValidIdArgs(args)) {
        throw new McpError(ErrorCode.InvalidParams, 'Pathway ID is required');
      }
    
      try {
        // Resolve pathway ID if it's a name
        const pathwayId = await this.resolvePathwayId(args.id);
        if (!pathwayId) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  error: `No pathway found for identifier: ${args.id}`,
                  suggestion: 'Try using a Reactome stable identifier (e.g., R-HSA-1640170) or search for the pathway first'
                }, null, 2),
              },
            ],
            isError: true,
          };
        }
    
        // Get basic pathway information first
        const pathwayInfo = await this.apiClient.get(`/data/query/${pathwayId}`);
    
        // Try alternative endpoints for hierarchy
        let ancestors = [];
        let children = [];
    
        try {
          // Try to get orthologous events (related pathways)
          const orthologousResponse = await this.apiClient.get(`/data/orthologous/${pathwayId}/pathways`);
          ancestors = orthologousResponse.data || [];
        } catch (e) {
          // Try to extract hierarchy info from basic pathway data
          if (pathwayInfo.data.hasEvent) {
            children = pathwayInfo.data.hasEvent.map((event: any) => ({
              id: event.stId || event.dbId,
              name: event.displayName || event.name,
              type: event.schemaClass || 'Event'
            }));
          }
        }
    
        const hierarchy = {
          pathwayId: pathwayId,
          originalQuery: args.id,
          basicInfo: {
            name: pathwayInfo.data.displayName || pathwayInfo.data.name,
            type: pathwayInfo.data.schemaClass,
            species: pathwayInfo.data.species?.[0]?.displayName
          },
          ancestors: ancestors.length > 0 ? ancestors.slice(0, 10).map((ancestor: any) => ({
            id: ancestor.stId || ancestor.dbId,
            name: ancestor.displayName || ancestor.name,
            type: ancestor.schemaClass || 'Pathway'
          })) : 'Ancestor information not available via current API',
          children: children.length > 0 ? children.slice(0, 10) : 'Child pathway information not available via current API',
          note: 'Hierarchy data may be limited due to API endpoint availability'
        };
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(hierarchy, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error getting pathway hierarchy: ${error instanceof Error ? error.message : 'Unknown error'}`,
            },
          ],
          isError: true,
        };
      }
    }
  • The tool schema defining the name, description, and input validation schema (requiring 'id' parameter of type string). This is part of the tools array registered with the MCP server.
    {
      name: 'get_pathway_hierarchy',
      description: 'Get hierarchical structure and parent/child relationships for a pathway',
      inputSchema: {
        type: 'object',
        properties: {
          id: { type: 'string', description: 'Reactome pathway stable identifier' },
        },
        required: ['id'],
      },
    },
  • src/index.ts:335-336 (registration)
    The switch case in the MCP request handler that routes calls to 'get_pathway_hierarchy' to the specific handler method.
    case 'get_pathway_hierarchy':
      return this.handleGetPathwayHierarchy(args);
  • Helper function used by the handler to resolve a pathway name or identifier to its Reactome stable ID via direct match or API search.
    private async resolvePathwayId(identifier: string): Promise<string | null> {
      // If it's already a stable identifier, return it
      if (identifier.match(/^R-[A-Z]{3}-\d+$/)) {
        return identifier;
      }
    
      // Search for the pathway by name
      try {
        const searchResponse = await this.apiClient.get('/search/query', {
          params: {
            query: identifier,
            types: 'Pathway',
            cluster: true
          }
        });
    
        if (searchResponse.data.results &&
            searchResponse.data.results.length > 0 &&
            searchResponse.data.results[0].entries &&
            searchResponse.data.results[0].entries.length > 0) {
          const resolvedId = searchResponse.data.results[0].entries[0].stId;
          return resolvedId;
        }
      } catch (error) {
        // Silently handle pathway resolution errors
      }
    
      return null;
    }
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 hierarchical structure and relationships, implying a read-only operation, but doesn't specify if it's safe, has rate limits, requires authentication, or what the output format looks like. This is a significant gap for a tool with no annotation coverage.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized for a simple tool, though it could be slightly more front-loaded with additional context to improve clarity.

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 the lack of annotations and output schema, the description is incomplete. It doesn't explain what the hierarchical structure looks like, how relationships are represented, or any potential errors or limitations. For a tool that likely returns complex data, this leaves significant gaps for an AI agent to understand its behavior.

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 input schema has 100% description coverage, with the 'id' parameter documented as a 'Reactome pathway stable identifier'. The description doesn't add any extra meaning beyond this, such as examples or constraints, so it meets the baseline score of 3 where 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 with a specific verb ('Get') and resource ('hierarchical structure and parent/child relationships for a pathway'), making it easy to understand what it does. However, it doesn't explicitly differentiate from sibling tools like 'get_pathway_details' or 'search_pathways', which might also provide structural information, so it doesn't reach the highest score.

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 prerequisites, context for usage, or compare it to sibling tools like 'get_pathway_details' or 'search_pathways', leaving the agent to infer usage based on the name alone.

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/Augmented-Nature/Reactome-MCP-Server'

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