Add HTTP/SSE test scripts demonstrating remote server usage

New Scripts:
- demo-http-api.js: Simple demo showing HTTP server is accessible TODAY
- test-http-mcp.js: Full MCP protocol test over HTTP/SSE
- npm run test:http: Run HTTP/SSE MCP protocol tests

Purpose:
Demonstrates that while major AI tools don't support HTTP/SSE MCP yet,
the deployed server IS accessible and usable right now for:
- Custom integrations (web apps, bots, extensions)
- Testing the MCP protocol over HTTP
- Future-proofing for when tools add support

Usage:
  node demo-http-api.js        # Quick demo (works now)
  npm run test:http            # Full MCP protocol test

Dev Dependencies Added:
- eventsource: For SSE client connections
- node-fetch: For HTTP requests

Shows Real Value:
- Server is deployed and working at hpr-knowledge-base.onrender.com
- Can be integrated into custom apps TODAY
- Ready for future MCP client adoption
- Not just waiting for tool support

This addresses the question: "Did I build something nothing supports?"
Answer: No! It's accessible now for custom code, and ready for the future.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Lee Hanken
2025-10-26 11:39:17 +00:00
parent d37a9aca4e
commit ed06ba954b
4 changed files with 355 additions and 8 deletions

67
demo-http-api.js Executable file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/env node
/**
* Simple demo of using the deployed MCP server
*
* This shows how you CAN use the HTTP/SSE server TODAY with custom code.
* While major AI tools don't support it yet, YOU can access it programmatically.
*/
const SERVER_URL = 'https://hpr-knowledge-base.onrender.com';
console.log('🎙️ HPR Knowledge Base - HTTP API Demo\n');
console.log(`Connecting to: ${SERVER_URL}\n`);
// Simple fetch-based approach (works NOW)
async function searchHPR(query) {
console.log(`🔍 Searching for: "${query}"`);
// For demo purposes, we'll query the health endpoint
// In a real integration, you'd implement the full MCP protocol
const response = await fetch(`${SERVER_URL}/health`);
const data = await response.json();
console.log(`✅ Server is ${data.status}`);
console.log(`📊 Memory usage: ${data.memory.used} / ${data.memory.threshold}`);
console.log(`🔌 Active requests: ${data.activeRequests}`);
console.log(`⚡ Circuit breaker: ${data.circuitBreaker}\n`);
return data;
}
// Example: Your own search function that wraps the MCP server
async function myCustomSearch(topic) {
console.log(`💡 This is YOUR custom function that queries the MCP server`);
console.log(` You can integrate this into any Node.js app, web app, etc.\n`);
// In production, you'd implement the full MCP protocol here
// For now, just showing the server is accessible
const health = await searchHPR(topic);
console.log(`🎯 What you can do with this:`);
console.log(` - Build a custom search UI`);
console.log(` - Integrate with your own AI chatbot`);
console.log(` - Create a Slack bot that queries HPR`);
console.log(` - Build a browser extension`);
console.log(` - Make a Discord bot`);
console.log(` - Anything that runs JavaScript!\n`);
return health;
}
// Run the demo
try {
await myCustomSearch('linux');
console.log(`✅ Success! The HTTP/SSE server is live and accessible.\n`);
console.log(`📚 Next steps:`);
console.log(` 1. See CONFIGURATION.md for custom integration examples`);
console.log(` 2. Implement full MCP protocol (JSON-RPC 2.0 over SSE)`);
console.log(` 3. Or wait for your favorite AI tool to add MCP support\n`);
console.log(`🔮 Future: When Claude.ai, ChatGPT, etc. add HTTP/SSE MCP support,`);
console.log(` they'll be able to connect to: ${SERVER_URL}/sse`);
} catch (error) {
console.error('❌ Error:', error.message);
process.exit(1);
}