Skip to main content
Glama

MCP Content Analyzer

by DuncanDam
mcp.ts4.59 kB
import { Hono } from 'hono'; import { zValidator } from '@hono/zod-validator'; import { z } from 'zod'; import { logger } from '../utils/logger.js'; const mcp: Hono = new Hono(); // Validation schemas const toolCallSchema = z.object({ tool: z.string(), arguments: z.record(z.string(), z.any()).optional() }); const workflowSchema = z.object({ input: z.string(), inputType: z.enum(['url', 'file', 'auto']).optional(), topic: z.string().optional(), extractedText: z.string().optional(), sourceDescription: z.string().optional() }); // List available tools mcp.get('/tools', (c) => { const tools = [ { name: 'test_connection', description: 'Test MCP server connection and basic functionality', category: 'system' }, { name: 'get_server_info', description: 'Get information about the MCP server', category: 'system' }, { name: 'analyze_content_workflow', description: 'Complete content analysis pipeline with intelligent fallback', category: 'workflow' }, { name: 'scrape_and_save_content', description: 'Complete workflow: scrape webpage content and save to Excel database', category: 'workflow' }, { name: 'scrape_webpage', description: 'Extract content from URLs with metadata', category: 'web' }, { name: 'check_url_accessibility', description: 'Validate URLs before processing', category: 'web' }, { name: 'read_document', description: 'Extract content from PDF, DOCX, TXT, RTF files', category: 'document' }, { name: 'analyze_document_metadata', description: 'Get document properties without full extraction', category: 'document' }, { name: 'extract_document_text', description: 'Pure text extraction with length limits', category: 'document' }, { name: 'process_extracted_text', description: 'Process Claude-extracted text from images', category: 'document' }, { name: 'add_content_entry', description: 'Add new entries to Excel database', category: 'excel' }, { name: 'search_similar_content', description: 'Find related existing content', category: 'excel' }, { name: 'get_topic_categories', description: 'Retrieve available topic categories', category: 'excel' }, { name: 'get_database_stats', description: 'Return Excel database metrics and analytics', category: 'excel' } ]; return c.json({ success: true, tools, totalTools: tools.length, categories: { system: tools.filter(t => t.category === 'system').length, workflow: tools.filter(t => t.category === 'workflow').length, web: tools.filter(t => t.category === 'web').length, document: tools.filter(t => t.category === 'document').length, excel: tools.filter(t => t.category === 'excel').length } }); }); // Execute tool call mcp.post('/call', zValidator('json', toolCallSchema), async (c) => { const { tool, arguments: args } = c.req.valid('json'); logger.info('Hono tool call received', { tool, args }); try { // This would integrate with the actual MCP server // For now, return a placeholder response return c.json({ success: true, message: `Tool ${tool} executed successfully via Hono`, tool, arguments: args, timestamp: new Date().toISOString() }); } catch (error) { logger.error('Hono tool call failed', { tool, error: error instanceof Error ? error.message : String(error) }); return c.json({ success: false, error: { message: error instanceof Error ? error.message : 'Unknown error', tool, timestamp: new Date().toISOString() } }, 500); } }); // Workflow endpoints mcp.post('/workflow/analyze', zValidator('json', workflowSchema), async (c) => { const data = c.req.valid('json'); logger.info('Workflow analysis requested', data); return c.json({ success: true, message: 'Workflow analysis started', workflow: 'analyze_content_workflow', input: data.input, status: 'processing', timestamp: new Date().toISOString() }); }); // Get workflow status mcp.get('/workflow/:id', (c) => { const id = c.req.param('id'); return c.json({ success: true, workflowId: id, status: 'completed', result: 'Sample workflow result', timestamp: new Date().toISOString() }); }); export { mcp as mcpRoutes };

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/DuncanDam/my-mcp'

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