Skip to main content
Glama

get_pathway_hierarchy

Retrieve hierarchical structure and parent-child relationships of a pathway in Reactome using its stable identifier to analyze pathway organization and dependencies.

Instructions

Get hierarchical structure and parent/child relationships for a pathway

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesReactome pathway stable identifier

Implementation Reference

  • src/index.ts:271-281 (registration)
    Tool registration in ListToolsRequestSchema, including name, description, and input schema definition for get_pathway_hierarchy.
    { 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'], }, },
  • The primary handler function that executes the get_pathway_hierarchy tool. Validates input, resolves pathway ID, fetches data from Reactome API, constructs hierarchy (ancestors/children), and returns formatted JSON response.
    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, }; } }
  • Helper function used by the handler to resolve pathway names to stable Reactome IDs via search API.
    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; }
  • Input validation helper function used in the handler to validate the 'id' argument.
    const isValidIdArgs = (args: any): args is { id: string } => { return ( typeof args === 'object' && args !== null && typeof args.id === 'string' && args.id.length > 0 );

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

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