Skip to content

Commit ddc78d6

Browse files
author
Marvin Zhang
committed
refactor: Update MCP server configuration and add SQLite error handling; introduce test script for MCP functionality
1 parent 82e8ef0 commit ddc78d6

File tree

7 files changed

+56
-19
lines changed

7 files changed

+56
-19
lines changed

.vscode/mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"args": [
1010
"--filter",
1111
"@devlog/mcp-server",
12-
"dev"
12+
"start"
1313
]
1414
},
1515
"playwright": {

packages/core/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Core devlog management functionality",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",
7+
"type": "module",
78
"files": [
89
"build/**/*",
910
"README.md",
@@ -39,7 +40,9 @@
3940
},
4041
"license": "MIT",
4142
"dependencies": {
42-
"@devlog/types": "workspace:*",
43+
"@devlog/types": "workspace:*"
44+
},
45+
"peerDependencies": {
4346
"better-sqlite3": "^11.0.0",
4447
"pg": "^8.12.0",
4548
"mysql2": "^3.11.0"

packages/core/src/storage/sqlite-storage.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ export class SQLiteStorageProvider implements StorageProvider {
1818
async initialize(): Promise<void> {
1919
// Dynamic import to make better-sqlite3 optional
2020
try {
21-
const sqlite3Module = await import("better-sqlite3" as any);
21+
// Use eval to prevent TypeScript from transforming the import
22+
const dynamicImport = eval('(specifier) => import(specifier)');
23+
const sqlite3Module = await dynamicImport("better-sqlite3");
2224
const Database = sqlite3Module.default;
2325

2426
this.db = new Database(this.filePath, this.options);
25-
} catch (error) {
26-
throw new Error("better-sqlite3 is required for SQLite storage. Install it with: npm install better-sqlite3");
27+
} catch (error: any) {
28+
console.error("Failed to initialize SQLite storage:", error);
29+
throw new Error("Failed to initialize SQLite storage: " + error.message);
2730
}
2831

2932
// Create tables

packages/mcp-server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "MCP server for managing development logs and working notes",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",
7-
"type": "module",
87
"files": [
98
"build/**/*",
109
"README.md",
@@ -45,7 +44,8 @@
4544
"dependencies": {
4645
"@modelcontextprotocol/sdk": "^1.0.0",
4746
"@devlog/types": "workspace:*",
48-
"@devlog/core": "workspace:*"
47+
"@devlog/core": "workspace:*",
48+
"better-sqlite3": "^11.10.0"
4949
},
5050
"devDependencies": {
5151
"@devlog/types": "workspace:*",

packages/mcp-server/tsconfig.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"target": "ES2022",
44
"module": "ESNext",
5-
"moduleResolution": "bundler",
5+
"moduleResolution": "node",
66
"allowSyntheticDefaultImports": true,
77
"esModuleInterop": true,
88
"allowImportingTsExtensions": false,
@@ -13,17 +13,8 @@
1313
"rootDir": "./src",
1414
"declaration": true,
1515
"declarationMap": true,
16-
"sourceMap": true,
17-
"composite": true
16+
"sourceMap": true
1817
},
1918
"include": ["src/**/*"],
20-
"exclude": ["node_modules", "build", "src/**/*.test.ts", "src/__tests__"],
21-
"references": [
22-
{
23-
"path": "../types"
24-
},
25-
{
26-
"path": "../core"
27-
}
28-
]
19+
"exclude": ["node_modules", "build", "src/**/*.test.ts", "src/__tests__"]
2920
}

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-mcp-direct.mjs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Test script to verify MCP functionality works correctly
5+
*/
6+
7+
import { MCPDevlogAdapter } from './packages/mcp-server/build/mcp-adapter.js';
8+
9+
async function testMCPFunctionality() {
10+
console.log('Testing MCP functionality...');
11+
12+
const adapter = new MCPDevlogAdapter(process.cwd());
13+
14+
try {
15+
console.log('Creating test devlog entry...');
16+
const result = await adapter.findOrCreateDevlog({
17+
title: 'Test MCP Server Functionality',
18+
type: 'task',
19+
description: 'Testing the MCP server to ensure it can create and manage devlog entries after the cleanup and build process',
20+
priority: 'medium'
21+
});
22+
23+
console.log('Success!');
24+
console.log(result);
25+
26+
console.log('\nListing active devlogs...');
27+
const activeResult = await adapter.getActiveContext();
28+
console.log(activeResult);
29+
30+
} catch (error) {
31+
console.error('Error:', error.message);
32+
} finally {
33+
await adapter.dispose();
34+
}
35+
}
36+
37+
testMCPFunctionality().catch(console.error);

0 commit comments

Comments
 (0)