- Add reminders page with navigation support - Upgrade BMad builder module to skills-based architecture - Refactor MCP server: extract tools and auth into separate modules - Add connections cache, custom AI provider support - Update prisma schema and generated client - Various UI/UX improvements and i18n updates - Add service worker for PWA support Made-with: Cursor
68 lines
1.9 KiB
JavaScript
68 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Memento MCP Server - Stdio Transport
|
|
*
|
|
* For local CLI usage. Connects directly to the SQLite database.
|
|
*
|
|
* Environment variables:
|
|
* DATABASE_URL - Prisma database URL (default: ../../keep-notes/prisma/dev.db)
|
|
* USER_ID - Optional user ID to filter data
|
|
* APP_BASE_URL - Optional Next.js app URL for AI features (default: http://localhost:3000)
|
|
*/
|
|
|
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
import { PrismaClient } from '../keep-notes/prisma/client-generated/index.js';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, join } from 'path';
|
|
import { registerTools } from './tools.js';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
// Database path - auto-detect relative to project
|
|
const defaultDbPath = join(__dirname, '..', 'keep-notes', 'prisma', 'dev.db');
|
|
const databaseUrl = process.env.DATABASE_URL || `file:${defaultDbPath}`;
|
|
|
|
const prisma = new PrismaClient({
|
|
datasources: {
|
|
db: { url: databaseUrl },
|
|
},
|
|
});
|
|
|
|
const server = new Server(
|
|
{
|
|
name: 'memento-mcp-server',
|
|
version: '3.0.0',
|
|
},
|
|
{
|
|
capabilities: { tools: {} },
|
|
},
|
|
);
|
|
|
|
const appBaseUrl = process.env.APP_BASE_URL || 'http://localhost:3000';
|
|
|
|
registerTools(server, prisma, {
|
|
userId: process.env.USER_ID || null,
|
|
appBaseUrl,
|
|
});
|
|
|
|
async function main() {
|
|
const transport = new StdioServerTransport();
|
|
await server.connect(transport);
|
|
console.error(`Memento MCP Server v3.0.0 (stdio)`);
|
|
console.error(`Database: ${databaseUrl}`);
|
|
console.error(`App URL: ${appBaseUrl}`);
|
|
console.error(`User filter: ${process.env.USER_ID || 'none (all data)'}`);
|
|
}
|
|
|
|
main().catch((error) => {
|
|
console.error('Server error:', error);
|
|
process.exit(1);
|
|
});
|
|
|
|
process.on('SIGINT', async () => {
|
|
await prisma.$disconnect();
|
|
process.exit(0);
|
|
});
|