From d8e76de175d7c2463a96ae6ae8e711e6b434439c Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 21 Jan 2026 11:01:08 -0500 Subject: [PATCH] Add MCP discovery endpoint and document static pages functionality - Add /.well-known/mcp.json endpoint for MCP protocol discovery - Document static pages functionality in about.md - Document MCP endpoint availability in about.md - MCP endpoint provides API discovery for AI assistants --- about.md | 24 ++++++++++++++++++++++++ server.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/about.md b/about.md index 080a04e..400b38d 100644 --- a/about.md +++ b/about.md @@ -12,6 +12,30 @@ It's important to understand that this service is purely plain text-based. Data The source code for this Hastebin instance is available at our Git repository: [Nixius/hastebin](https://git.nixc.us/Nixius/hastebin.git). Feel free to explore, contribute, or use it to set up your own instance. +## Static Pages + +Hastebin supports static documents that are permanently stored and never expire. These documents are loaded at server startup and can be accessed like regular pastes. Currently, the following static documents are available: + +- **About page**: Accessible at `/about` (this page) + +Static documents are configured in the server configuration and are useful for hosting documentation, help pages, or other content that should persist indefinitely. Unlike regular pastes, static documents do not expire and are always available. + +## MCP (Model Context Protocol) Support + +Hastebin provides an MCP discovery endpoint for AI assistants and tools that support the Model Context Protocol. You can discover Hastebin's capabilities by accessing: + +``` +/.well-known/mcp.json +``` + +This endpoint returns information about: +- Available API endpoints (create, read, read raw) +- Service capabilities +- Base URL and protocol information +- List of static documents + +The MCP endpoint allows AI assistants to automatically discover and interact with Hastebin's paste creation and retrieval functionality. + ## Tools for Uploading ### haste CLI Tool diff --git a/server.js b/server.js index 2131727..a51db0e 100644 --- a/server.js +++ b/server.js @@ -150,6 +150,49 @@ if (config.rateLimits) { // first look at API calls app.use(route(function(router) { + // MCP discovery endpoint + router.get('/.well-known/mcp.json', function(request, response) { + var protocol = request.headers['x-forwarded-proto'] || + (request.connection.encrypted ? 'https' : 'http'); + var host = request.headers.host || (config.host + ':' + config.port); + var baseUrl = protocol + '://' + host; + + var mcpInfo = { + name: 'hastebin', + version: '0.2.0', + description: 'Hastebin pastebin service - create and retrieve text documents', + capabilities: { + resources: ['paste'], + tools: ['create_paste', 'read_paste', 'read_raw_paste'] + }, + endpoints: { + create: { + method: 'POST', + path: '/documents', + description: 'Create a new paste', + contentType: 'text/plain' + }, + read: { + method: 'GET', + path: '/documents/:id', + description: 'Read a paste as JSON', + contentType: 'application/json' + }, + readRaw: { + method: 'GET', + path: '/raw/:id', + description: 'Read a paste as raw text', + contentType: 'text/plain' + } + }, + baseUrl: baseUrl, + staticDocuments: Object.keys(config.documents) + }; + + response.writeHead(200, { 'content-type': 'application/json' }); + response.end(JSON.stringify(mcpInfo, null, 2)); + }); + // get raw documents - support getting with extension router.get('/raw/:id', function(request, response) { var key = request.params.id.split('.')[0];