Implement remote MCP server deployment capabilities

- Add HTTP/JSON-RPC server for remote MCP access
- Configure domain and authentication via environment variables
- Create comprehensive remote deployment documentation
- Support both local (stdio) and remote (HTTP) deployment modes
- Add PM2 and Nginx configuration examples
- Update README with remote server instructions

The server can now be deployed on a VM (e.g., Hetzner) and accessed
from Claude Desktop over HTTPS using the configured domain.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-06-08 07:31:12 +00:00
parent d32af279c0
commit ee8aa729c1
9 changed files with 1867 additions and 17 deletions

View File

@@ -0,0 +1,49 @@
import { Request, Response, NextFunction } from 'express';
import { logger } from './logger';
/**
* Express middleware for authenticating requests with Bearer tokens
*/
export function authenticateRequest(authToken?: string) {
return (req: Request, res: Response, next: NextFunction): void => {
if (!authToken) {
// No auth required
return next();
}
const authHeader = req.headers['authorization'];
if (!authHeader) {
logger.warn('Missing authorization header', {
ip: req.ip,
path: req.path,
});
res.status(401).json({
error: 'Unauthorized',
message: 'Missing authorization header',
});
return;
}
// Support both "Bearer TOKEN" and just "TOKEN" formats
const providedToken = authHeader.startsWith('Bearer ')
? authHeader.substring(7)
: authHeader;
if (providedToken !== authToken) {
logger.warn('Invalid authentication token', {
ip: req.ip,
path: req.path,
});
res.status(401).json({
error: 'Unauthorized',
message: 'Invalid authentication token',
});
return;
}
next();
};
}