Skip to main content
Glama
pythagraph
by pythagraph

get_graph_summary

Generate a concise summary of graph data, including overview statistics, node/edge type distributions, and key insights. Optionally include detailed node and edge information for comprehensive analysis using the Pythagraph RED API.

Instructions

Get a concise summary of graph data from Pythagraph RED API. Provides overview statistics, node/edge type distributions, and key insights without overwhelming detail. Use includeDetails=true for more comprehensive analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
graphIdYesThe unique identifier for the graph to get summary
includeDetailsNoInclude detailed node and edge information

Implementation Reference

  • Handler logic for the get_graph_summary tool within the CallToolRequestSchema handler: parses arguments, fetches graph data using fetchGraphData, formats the summary using formatGraphSummary, and returns the text content.
    case "get_graph_summary": { const parsed = GetGraphSummaryArgsSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for get_graph_summary: ${parsed.error}`); } const graphData = await fetchGraphData(parsed.data.graphId); const summary = formatGraphSummary(graphData, parsed.data.includeDetails); return { content: [{ type: "text", text: summary }], }; }
  • Zod schema defining the input parameters for the get_graph_summary tool: graphId (required string) and includeDetails (optional boolean, default false).
    const GetGraphSummaryArgsSchema = z.object({ graphId: z.string().describe('The unique identifier for the graph to get summary'), includeDetails: z.boolean().default(false).describe('Include detailed node and edge information'), });
  • index.ts:264-268 (registration)
    Registration of the get_graph_summary tool in the ListToolsRequestSchema response, specifying name, description, and derived JSON schema from Zod.
    { name: "get_graph_summary", description: "Get a concise summary of graph data from Pythagraph RED API. Provides overview statistics, node/edge type distributions, and key insights without overwhelming detail. Use includeDetails=true for more comprehensive analysis.", inputSchema: zodToJsonSchema(GetGraphSummaryArgsSchema) as ToolInput, },
  • Helper function specifically used by get_graph_summary to format PythagraphResponse data into a markdown summary, including basic info, description, key insights (max/min values), and optionally full table details via formatGraphDataAsTable.
    function formatGraphSummary(data: PythagraphResponse, includeDetails: boolean = false): string { let result = ""; result += `# ${data.graphNm} - 요약\n\n`; // 기본 정보 result += `📊 **Graph ID**: ${data.graphId}\n`; result += `📊 **데이터 건수**: ${data.graphData.length}건\n`; result += `📊 **단위**: ${data.unitDivNm} (${data.unitNm})\n`; result += `📅 **등록일**: ${data.regTime}\n\n`; // 설명 if (data.graphDet) { const cleanDescription = data.graphDet .replace(/<[^>]*>/g, '') .replace(/&quot;/g, '"') .replace(//g, '') .trim(); result += `**설명**: ${cleanDescription}\n\n`; } // 빠른 통계 if (data.graphData && data.graphData.length > 0) { const valueColumnIndex = data.cols.findIndex(col => col.includes('값')); if (valueColumnIndex !== -1) { const values = data.graphData .map(row => parseFloat(row[valueColumnIndex])) .filter(val => !isNaN(val)); if (values.length > 0) { const total = values.reduce((sum, val) => sum + val, 0); const max = Math.max(...values); const min = Math.min(...values); // 최고값과 최저값 항목 찾기 const maxIndex = data.graphData.findIndex(row => parseFloat(row[valueColumnIndex]) === max); const minIndex = data.graphData.findIndex(row => parseFloat(row[valueColumnIndex]) === min); result += "## 🔍 핵심 인사이트\n\n"; if (maxIndex !== -1) { const categoryIndex = data.cols.findIndex(col => col.includes('MBTI') || col.includes('유형')); const maxCategory = categoryIndex !== -1 ? data.graphData[maxIndex][categoryIndex] : data.graphData[maxIndex][1]; result += `🏆 **최고**: ${maxCategory} (${(max * 100).toFixed(1)}%)\n`; } if (minIndex !== -1) { const categoryIndex = data.cols.findIndex(col => col.includes('MBTI') || col.includes('유형')); const minCategory = categoryIndex !== -1 ? data.graphData[minIndex][categoryIndex] : data.graphData[minIndex][1]; result += `📉 **최저**: ${minCategory} (${(min * 100).toFixed(1)}%)\n`; } result += `📊 **총합**: ${(total * 100).toFixed(1)}%\n\n`; } } } if (includeDetails) { result += "\n---\n\n" + formatGraphDataAsTable(data); } else { result += "\n*`includeDetails: true` 옵션을 사용하면 전체 데이터 테이블을 볼 수 있습니다.*\n"; } return result; }
  • Shared helper function to fetch graph data from the Pythagraph RED API endpoint, used by both get_graph_data and get_graph_summary tools.
    async function fetchGraphData(graphId: string): Promise<PythagraphResponse> { const url = `${API_BASE_URL}?graphId=${encodeURIComponent(graphId)}`; try { const response = await fetch(url, { method: 'GET', headers: { 'Accept': 'application/json', 'User-Agent': 'MCP-PythagraphRED-Server/0.1.0', }, // timeout: 30000, // 30 second timeout }); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json() as PythagraphResponse; if (data.message !== 'OK') { throw new Error(`API Error: ${data.message}`); } return data; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to fetch graph data: ${error.message}`); } throw new Error('Failed to fetch graph data: Unknown error'); } }

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/pythagraph/pythagraph-red-mcp'

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