memory-journal-mcp 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +88 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +76 -0
- package/.github/ISSUE_TEMPLATE/config.yml +11 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +89 -0
- package/.github/ISSUE_TEMPLATE/question.md +63 -0
- package/.github/dependabot.yml +110 -0
- package/.github/pull_request_template.md +110 -0
- package/.github/workflows/DOCKER_DEPLOYMENT_SETUP.md +346 -0
- package/.github/workflows/codeql.yml +45 -0
- package/.github/workflows/dependabot-auto-merge.yml +42 -0
- package/.github/workflows/docker-publish.yml +277 -0
- package/.github/workflows/lint-and-test.yml +58 -0
- package/.github/workflows/publish-npm.yml +75 -0
- package/.github/workflows/secrets-scanning.yml +32 -0
- package/.github/workflows/security-update.yml +99 -0
- package/.memory-journal-team.db +0 -0
- package/.trivyignore +18 -0
- package/CHANGELOG.md +19 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +209 -0
- package/DOCKER_README.md +377 -0
- package/Dockerfile +64 -0
- package/LICENSE +21 -0
- package/README.md +461 -0
- package/SECURITY.md +200 -0
- package/VERSION +1 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +42 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants/ServerInstructions.d.ts +8 -0
- package/dist/constants/ServerInstructions.d.ts.map +1 -0
- package/dist/constants/ServerInstructions.js +26 -0
- package/dist/constants/ServerInstructions.js.map +1 -0
- package/dist/database/SqliteAdapter.d.ts +198 -0
- package/dist/database/SqliteAdapter.d.ts.map +1 -0
- package/dist/database/SqliteAdapter.js +736 -0
- package/dist/database/SqliteAdapter.js.map +1 -0
- package/dist/filtering/ToolFilter.d.ts +63 -0
- package/dist/filtering/ToolFilter.d.ts.map +1 -0
- package/dist/filtering/ToolFilter.js +242 -0
- package/dist/filtering/ToolFilter.js.map +1 -0
- package/dist/github/GitHubIntegration.d.ts +91 -0
- package/dist/github/GitHubIntegration.d.ts.map +1 -0
- package/dist/github/GitHubIntegration.js +317 -0
- package/dist/github/GitHubIntegration.js.map +1 -0
- package/dist/handlers/prompts/index.d.ts +28 -0
- package/dist/handlers/prompts/index.d.ts.map +1 -0
- package/dist/handlers/prompts/index.js +366 -0
- package/dist/handlers/prompts/index.js.map +1 -0
- package/dist/handlers/resources/index.d.ts +27 -0
- package/dist/handlers/resources/index.d.ts.map +1 -0
- package/dist/handlers/resources/index.js +453 -0
- package/dist/handlers/resources/index.js.map +1 -0
- package/dist/handlers/tools/index.d.ts +26 -0
- package/dist/handlers/tools/index.d.ts.map +1 -0
- package/dist/handlers/tools/index.js +982 -0
- package/dist/handlers/tools/index.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/server/McpServer.d.ts +18 -0
- package/dist/server/McpServer.d.ts.map +1 -0
- package/dist/server/McpServer.js +171 -0
- package/dist/server/McpServer.js.map +1 -0
- package/dist/types/index.d.ts +300 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +15 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/McpLogger.d.ts +61 -0
- package/dist/utils/McpLogger.d.ts.map +1 -0
- package/dist/utils/McpLogger.js +113 -0
- package/dist/utils/McpLogger.js.map +1 -0
- package/dist/utils/logger.d.ts +30 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +70 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/vector/VectorSearchManager.d.ts +63 -0
- package/dist/vector/VectorSearchManager.d.ts.map +1 -0
- package/dist/vector/VectorSearchManager.js +235 -0
- package/dist/vector/VectorSearchManager.js.map +1 -0
- package/docker-compose.yml +37 -0
- package/eslint.config.js +86 -0
- package/mcp-config-example.json +21 -0
- package/package.json +71 -0
- package/releases/release-notes-v2.2.0.md +165 -0
- package/releases/release-notes.md +214 -0
- package/releases/v3.0.0.md +236 -0
- package/server.json +42 -0
- package/src/cli.ts +52 -0
- package/src/constants/ServerInstructions.ts +25 -0
- package/src/database/SqliteAdapter.ts +952 -0
- package/src/filtering/ToolFilter.ts +271 -0
- package/src/github/GitHubIntegration.ts +409 -0
- package/src/handlers/prompts/index.ts +420 -0
- package/src/handlers/resources/index.ts +529 -0
- package/src/handlers/tools/index.ts +1081 -0
- package/src/index.ts +53 -0
- package/src/server/McpServer.ts +230 -0
- package/src/types/index.ts +435 -0
- package/src/types/sql.js.d.ts +34 -0
- package/src/utils/McpLogger.ts +155 -0
- package/src/utils/logger.ts +98 -0
- package/src/vector/VectorSearchManager.ts +277 -0
- package/tools.json +300 -0
- package/tsconfig.json +51 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* memory-journal-mcp - Public API
|
|
3
|
+
*
|
|
4
|
+
* Exports the main components for programmatic use.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Server
|
|
8
|
+
export { createServer, SqliteAdapter } from './server/McpServer.js';
|
|
9
|
+
|
|
10
|
+
// Types
|
|
11
|
+
export type {
|
|
12
|
+
ToolGroup,
|
|
13
|
+
MetaGroup,
|
|
14
|
+
ToolFilterRule,
|
|
15
|
+
ToolFilterConfig,
|
|
16
|
+
ToolAnnotations,
|
|
17
|
+
ResourceAnnotations,
|
|
18
|
+
ToolDefinition,
|
|
19
|
+
ResourceDefinition,
|
|
20
|
+
PromptDefinition,
|
|
21
|
+
EntryType,
|
|
22
|
+
SignificanceType,
|
|
23
|
+
RelationshipType,
|
|
24
|
+
JournalEntry,
|
|
25
|
+
Tag,
|
|
26
|
+
Relationship,
|
|
27
|
+
Embedding,
|
|
28
|
+
GitHubProject,
|
|
29
|
+
GitHubIssue,
|
|
30
|
+
GitHubPullRequest,
|
|
31
|
+
GitHubWorkflowRun,
|
|
32
|
+
ProjectContext,
|
|
33
|
+
ServerConfig,
|
|
34
|
+
} from './types/index.js';
|
|
35
|
+
|
|
36
|
+
export { DEFAULT_CONFIG } from './types/index.js';
|
|
37
|
+
|
|
38
|
+
// Filtering
|
|
39
|
+
export {
|
|
40
|
+
TOOL_GROUPS,
|
|
41
|
+
META_GROUPS,
|
|
42
|
+
getAllToolNames,
|
|
43
|
+
getToolGroup,
|
|
44
|
+
parseToolFilter,
|
|
45
|
+
isToolEnabled,
|
|
46
|
+
filterTools,
|
|
47
|
+
getToolFilterFromEnv,
|
|
48
|
+
calculateTokenSavings,
|
|
49
|
+
getFilterSummary,
|
|
50
|
+
} from './filtering/ToolFilter.js';
|
|
51
|
+
|
|
52
|
+
// Logger
|
|
53
|
+
export { logger } from './utils/logger.js';
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Journal MCP Server - Main Server
|
|
3
|
+
*
|
|
4
|
+
* MCP server implementation with tools, resources, and prompts.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
import type { Variables } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';
|
|
9
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
|
|
12
|
+
import { SqliteAdapter } from '../database/SqliteAdapter.js';
|
|
13
|
+
import { VectorSearchManager } from '../vector/VectorSearchManager.js';
|
|
14
|
+
import { GitHubIntegration } from '../github/GitHubIntegration.js';
|
|
15
|
+
import { logger } from '../utils/logger.js';
|
|
16
|
+
import {
|
|
17
|
+
parseToolFilter,
|
|
18
|
+
getToolFilterFromEnv,
|
|
19
|
+
getFilterSummary,
|
|
20
|
+
type ToolFilterConfig
|
|
21
|
+
} from '../filtering/ToolFilter.js';
|
|
22
|
+
import { getTools, callTool } from '../handlers/tools/index.js';
|
|
23
|
+
import { getResources, readResource } from '../handlers/resources/index.js';
|
|
24
|
+
import { getPrompts, getPrompt } from '../handlers/prompts/index.js';
|
|
25
|
+
|
|
26
|
+
export interface ServerOptions {
|
|
27
|
+
transport: 'stdio' | 'http';
|
|
28
|
+
port?: number;
|
|
29
|
+
dbPath: string;
|
|
30
|
+
toolFilter?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Create and start the MCP server
|
|
35
|
+
*/
|
|
36
|
+
export async function createServer(options: ServerOptions): Promise<void> {
|
|
37
|
+
const { transport, dbPath, toolFilter } = options;
|
|
38
|
+
|
|
39
|
+
// Initialize database (async for sql.js)
|
|
40
|
+
const db = new SqliteAdapter(dbPath);
|
|
41
|
+
await db.initialize();
|
|
42
|
+
logger.info('Database initialized', { module: 'McpServer', dbPath });
|
|
43
|
+
|
|
44
|
+
// Initialize vector search manager (lazy loading - model loads on first use)
|
|
45
|
+
const vectorManager = new VectorSearchManager(dbPath);
|
|
46
|
+
logger.info('Vector search manager created (lazy initialization)', { module: 'McpServer' });
|
|
47
|
+
|
|
48
|
+
// Initialize GitHub integration
|
|
49
|
+
const github = new GitHubIntegration();
|
|
50
|
+
logger.info('GitHub integration initialized', { module: 'McpServer', hasToken: github.isApiAvailable() });
|
|
51
|
+
|
|
52
|
+
// Parse tool filter
|
|
53
|
+
let filterConfig: ToolFilterConfig | null = null;
|
|
54
|
+
if (toolFilter) {
|
|
55
|
+
filterConfig = parseToolFilter(toolFilter);
|
|
56
|
+
logger.info('Tool filter applied', {
|
|
57
|
+
module: 'McpServer',
|
|
58
|
+
summary: getFilterSummary(filterConfig)
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
filterConfig = getToolFilterFromEnv();
|
|
62
|
+
if (filterConfig) {
|
|
63
|
+
logger.info('Tool filter from env', {
|
|
64
|
+
module: 'McpServer',
|
|
65
|
+
summary: getFilterSummary(filterConfig)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Create MCP server
|
|
71
|
+
const server = new McpServer({
|
|
72
|
+
name: 'memory-journal-mcp',
|
|
73
|
+
version: '3.0.0-alpha.1',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Get filtered tools and register them dynamically
|
|
77
|
+
const tools = getTools(db, filterConfig, vectorManager, github);
|
|
78
|
+
for (const tool of tools) {
|
|
79
|
+
const toolDef = tool as {
|
|
80
|
+
name: string;
|
|
81
|
+
description?: string;
|
|
82
|
+
inputSchema?: z.ZodType;
|
|
83
|
+
annotations?: Record<string, unknown>;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Build tool options matching MCP SDK expectations
|
|
87
|
+
const toolOptions: Record<string, unknown> = {
|
|
88
|
+
description: toolDef.description ?? '',
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
if (toolDef.inputSchema) {
|
|
92
|
+
toolOptions['inputSchema'] = toolDef.inputSchema;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (toolDef.annotations) {
|
|
96
|
+
toolOptions['annotations'] = toolDef.annotations;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
server.registerTool(
|
|
100
|
+
toolDef.name,
|
|
101
|
+
toolOptions as { description?: string; inputSchema?: z.ZodType },
|
|
102
|
+
async (args: unknown) => {
|
|
103
|
+
try {
|
|
104
|
+
const result = await callTool(toolDef.name, args as Record<string, unknown>, db, vectorManager, github);
|
|
105
|
+
return {
|
|
106
|
+
content: [{
|
|
107
|
+
type: 'text' as const,
|
|
108
|
+
text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
|
|
109
|
+
}],
|
|
110
|
+
};
|
|
111
|
+
} catch (error) {
|
|
112
|
+
return {
|
|
113
|
+
content: [{
|
|
114
|
+
type: 'text' as const,
|
|
115
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
116
|
+
}],
|
|
117
|
+
isError: true,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Register resources
|
|
125
|
+
const resources = getResources();
|
|
126
|
+
for (const resource of resources) {
|
|
127
|
+
const resDef = resource as { uri: string; name: string; description?: string; mimeType?: string };
|
|
128
|
+
|
|
129
|
+
// Check if this is a template URI (contains {variable} patterns)
|
|
130
|
+
const isTemplate = resDef.uri.includes('{');
|
|
131
|
+
|
|
132
|
+
if (isTemplate) {
|
|
133
|
+
// Use ResourceTemplate for parametrized URIs
|
|
134
|
+
const template = new ResourceTemplate(
|
|
135
|
+
resDef.uri,
|
|
136
|
+
{ list: undefined } // No enumeration support needed
|
|
137
|
+
);
|
|
138
|
+
server.registerResource(
|
|
139
|
+
resDef.name,
|
|
140
|
+
template,
|
|
141
|
+
{ description: resDef.description ?? '', mimeType: resDef.mimeType ?? 'application/json' },
|
|
142
|
+
async (uri: URL, _variables: Variables) => {
|
|
143
|
+
const result = await readResource(uri.href, db, vectorManager, filterConfig, github);
|
|
144
|
+
return {
|
|
145
|
+
contents: [{
|
|
146
|
+
uri: uri.href,
|
|
147
|
+
mimeType: resDef.mimeType ?? 'application/json',
|
|
148
|
+
text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
|
|
149
|
+
}],
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
} else {
|
|
154
|
+
server.registerResource(
|
|
155
|
+
resDef.name,
|
|
156
|
+
resDef.uri,
|
|
157
|
+
{ description: resDef.description ?? '', mimeType: resDef.mimeType ?? 'application/json' },
|
|
158
|
+
async (uri: URL) => {
|
|
159
|
+
const result = await readResource(uri.href, db, vectorManager, filterConfig, github);
|
|
160
|
+
return {
|
|
161
|
+
contents: [{
|
|
162
|
+
uri: uri.href,
|
|
163
|
+
mimeType: resDef.mimeType ?? 'application/json',
|
|
164
|
+
text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
|
|
165
|
+
}],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Register prompts
|
|
173
|
+
const prompts = getPrompts();
|
|
174
|
+
for (const prompt of prompts) {
|
|
175
|
+
const promptDef = prompt as {
|
|
176
|
+
name: string;
|
|
177
|
+
description?: string;
|
|
178
|
+
arguments?: { name: string; description: string; required?: boolean }[];
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// Build Zod schema from prompt.arguments definitions
|
|
182
|
+
const zodShape: Record<string, z.ZodType> = {};
|
|
183
|
+
if (promptDef.arguments) {
|
|
184
|
+
for (const arg of promptDef.arguments) {
|
|
185
|
+
zodShape[arg.name] = arg.required === true
|
|
186
|
+
? z.string().describe(arg.description)
|
|
187
|
+
: z.string().optional().describe(arg.description);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
server.registerPrompt(
|
|
192
|
+
promptDef.name,
|
|
193
|
+
{
|
|
194
|
+
description: promptDef.description ?? '',
|
|
195
|
+
argsSchema: zodShape
|
|
196
|
+
},
|
|
197
|
+
(providedArgs) => {
|
|
198
|
+
const args = providedArgs as Record<string, string>;
|
|
199
|
+
const promptResult = getPrompt(promptDef.name, args, db);
|
|
200
|
+
// Map to MCP SDK expected format
|
|
201
|
+
const result = {
|
|
202
|
+
messages: promptResult.messages.map(m => ({
|
|
203
|
+
role: m.role as 'user' | 'assistant',
|
|
204
|
+
content: m.content as { type: 'text'; text: string }
|
|
205
|
+
}))
|
|
206
|
+
};
|
|
207
|
+
return Promise.resolve(result);
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Start server based on transport
|
|
213
|
+
if (transport === 'stdio') {
|
|
214
|
+
const stdioTransport = new StdioServerTransport();
|
|
215
|
+
await server.connect(stdioTransport);
|
|
216
|
+
logger.info('MCP server started on stdio', { module: 'McpServer' });
|
|
217
|
+
} else {
|
|
218
|
+
// HTTP transport - TODO: implement SSE transport
|
|
219
|
+
throw new Error('HTTP transport not yet implemented');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Handle shutdown
|
|
223
|
+
process.on('SIGINT', () => {
|
|
224
|
+
logger.info('Shutting down...', { module: 'McpServer' });
|
|
225
|
+
db.close();
|
|
226
|
+
process.exit(0);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { SqliteAdapter };
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Journal MCP Server - Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types for the MCP server including tools, resources, prompts,
|
|
5
|
+
* database entities, and filtering.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Tool Filtering Types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Tool group identifiers for Memory Journal
|
|
14
|
+
*/
|
|
15
|
+
export type ToolGroup =
|
|
16
|
+
| 'core' // Entry CRUD: create, get_by_id, get_recent, create_minimal, test_simple
|
|
17
|
+
| 'search' // Search: search_entries, search_by_date_range, semantic_search
|
|
18
|
+
| 'analytics' // Analytics: get_statistics, get_cross_project_insights
|
|
19
|
+
| 'relationships' // Relationships: link_entries, visualize_relationships
|
|
20
|
+
| 'export' // Export: export_entries
|
|
21
|
+
| 'admin' // Admin: update_entry, delete_entry
|
|
22
|
+
| 'github' // Reserved for future GitHub-specific tools
|
|
23
|
+
| 'backup'; // Backup: backup_journal, list_backups, restore_backup
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Meta-group identifiers for common multi-group selections
|
|
27
|
+
*/
|
|
28
|
+
export type MetaGroup =
|
|
29
|
+
| 'starter' // core + search (~8 tools)
|
|
30
|
+
| 'essential' // core only (~5 tools)
|
|
31
|
+
| 'full' // all groups (~16 tools)
|
|
32
|
+
| 'readonly'; // everything except admin
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Tool filter rule
|
|
36
|
+
*/
|
|
37
|
+
export interface ToolFilterRule {
|
|
38
|
+
/** Rule type: include or exclude */
|
|
39
|
+
type: 'include' | 'exclude';
|
|
40
|
+
|
|
41
|
+
/** Target: group name or tool name */
|
|
42
|
+
target: string;
|
|
43
|
+
|
|
44
|
+
/** Whether target is a group (true) or individual tool (false) */
|
|
45
|
+
isGroup: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Parsed tool filter configuration
|
|
50
|
+
*/
|
|
51
|
+
export interface ToolFilterConfig {
|
|
52
|
+
/** Original filter string */
|
|
53
|
+
raw: string;
|
|
54
|
+
|
|
55
|
+
/** Parsed rules in order */
|
|
56
|
+
rules: ToolFilterRule[];
|
|
57
|
+
|
|
58
|
+
/** Set of enabled tool names after applying rules */
|
|
59
|
+
enabledTools: Set<string>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ============================================================================
|
|
63
|
+
// MCP 2025-11-25 Annotations
|
|
64
|
+
// ============================================================================
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* MCP Tool Annotations (MCP Spec 2025-11-25)
|
|
68
|
+
*
|
|
69
|
+
* Behavioral hints for AI clients to understand tool characteristics.
|
|
70
|
+
*/
|
|
71
|
+
export interface ToolAnnotations {
|
|
72
|
+
/** Tool does not modify state (idempotent reads) */
|
|
73
|
+
readOnlyHint?: boolean;
|
|
74
|
+
|
|
75
|
+
/** Tool may permanently delete/destroy data */
|
|
76
|
+
destructiveHint?: boolean;
|
|
77
|
+
|
|
78
|
+
/** Repeated calls with same args produce same result */
|
|
79
|
+
idempotentHint?: boolean;
|
|
80
|
+
|
|
81
|
+
/** Tool interacts with external services (network, APIs) */
|
|
82
|
+
openWorldHint?: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* MCP Resource Annotations (MCP Spec 2025-11-25)
|
|
87
|
+
*/
|
|
88
|
+
export interface ResourceAnnotations {
|
|
89
|
+
/** Intended audience: 'user' or 'assistant' */
|
|
90
|
+
audience?: ('user' | 'assistant')[];
|
|
91
|
+
|
|
92
|
+
/** Importance level from 0.0 (optional) to 1.0 (required) */
|
|
93
|
+
priority?: number;
|
|
94
|
+
|
|
95
|
+
/** ISO 8601 timestamp of last modification */
|
|
96
|
+
lastModified?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// Tool, Resource, Prompt Definitions
|
|
101
|
+
// ============================================================================
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Tool definition for registration
|
|
105
|
+
*/
|
|
106
|
+
export interface ToolDefinition {
|
|
107
|
+
/** Unique tool name */
|
|
108
|
+
name: string;
|
|
109
|
+
|
|
110
|
+
/** Human-readable display title (MCP 2025-11-25) */
|
|
111
|
+
title: string;
|
|
112
|
+
|
|
113
|
+
/** Human-readable description */
|
|
114
|
+
description: string;
|
|
115
|
+
|
|
116
|
+
/** Tool group for filtering */
|
|
117
|
+
group: ToolGroup;
|
|
118
|
+
|
|
119
|
+
/** Zod schema for input validation */
|
|
120
|
+
inputSchema: unknown;
|
|
121
|
+
|
|
122
|
+
/** Behavioral hints for AI clients */
|
|
123
|
+
annotations: ToolAnnotations;
|
|
124
|
+
|
|
125
|
+
/** Tool handler function */
|
|
126
|
+
handler: (params: unknown) => Promise<unknown>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Resource definition for MCP
|
|
131
|
+
*/
|
|
132
|
+
export interface ResourceDefinition {
|
|
133
|
+
/** Resource URI template */
|
|
134
|
+
uri: string;
|
|
135
|
+
|
|
136
|
+
/** Human-readable name */
|
|
137
|
+
name: string;
|
|
138
|
+
|
|
139
|
+
/** Human-readable display title */
|
|
140
|
+
title: string;
|
|
141
|
+
|
|
142
|
+
/** Description */
|
|
143
|
+
description: string;
|
|
144
|
+
|
|
145
|
+
/** MIME type */
|
|
146
|
+
mimeType: string;
|
|
147
|
+
|
|
148
|
+
/** Resource metadata annotations */
|
|
149
|
+
annotations?: ResourceAnnotations;
|
|
150
|
+
|
|
151
|
+
/** Resource handler - NOTE: db is passed at runtime, not in the definition */
|
|
152
|
+
handler: (uri: string) => Promise<unknown>;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Prompt definition for MCP
|
|
157
|
+
*/
|
|
158
|
+
export interface PromptDefinition {
|
|
159
|
+
/** Prompt name */
|
|
160
|
+
name: string;
|
|
161
|
+
|
|
162
|
+
/** Description */
|
|
163
|
+
description: string;
|
|
164
|
+
|
|
165
|
+
/** Argument definitions */
|
|
166
|
+
arguments?: {
|
|
167
|
+
name: string;
|
|
168
|
+
description: string;
|
|
169
|
+
required?: boolean;
|
|
170
|
+
}[];
|
|
171
|
+
|
|
172
|
+
/** Prompt handler */
|
|
173
|
+
handler: (args: Record<string, string>) => Promise<unknown>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ============================================================================
|
|
177
|
+
// Database Entity Types
|
|
178
|
+
// ============================================================================
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Entry types for journal entries
|
|
182
|
+
*/
|
|
183
|
+
export type EntryType =
|
|
184
|
+
| 'personal_reflection'
|
|
185
|
+
| 'project_decision'
|
|
186
|
+
| 'technical_achievement'
|
|
187
|
+
| 'bug_fix'
|
|
188
|
+
| 'feature_implementation'
|
|
189
|
+
| 'code_review'
|
|
190
|
+
| 'meeting_notes'
|
|
191
|
+
| 'learning'
|
|
192
|
+
| 'research'
|
|
193
|
+
| 'planning'
|
|
194
|
+
| 'retrospective'
|
|
195
|
+
| 'standup'
|
|
196
|
+
| 'other';
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Significance types for important entries
|
|
200
|
+
*/
|
|
201
|
+
export type SignificanceType =
|
|
202
|
+
| 'milestone'
|
|
203
|
+
| 'breakthrough'
|
|
204
|
+
| 'technical_breakthrough'
|
|
205
|
+
| 'decision'
|
|
206
|
+
| 'lesson_learned'
|
|
207
|
+
| 'blocker_resolved'
|
|
208
|
+
| 'release'
|
|
209
|
+
| null;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Relationship types between entries
|
|
213
|
+
*/
|
|
214
|
+
export type RelationshipType =
|
|
215
|
+
| 'evolves_from'
|
|
216
|
+
| 'references'
|
|
217
|
+
| 'implements'
|
|
218
|
+
| 'clarifies'
|
|
219
|
+
| 'response_to';
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Journal entry entity
|
|
223
|
+
*/
|
|
224
|
+
export interface JournalEntry {
|
|
225
|
+
id: number;
|
|
226
|
+
entryType: EntryType;
|
|
227
|
+
content: string;
|
|
228
|
+
timestamp: string;
|
|
229
|
+
isPersonal: boolean;
|
|
230
|
+
significanceType: SignificanceType;
|
|
231
|
+
autoContext: string | null;
|
|
232
|
+
deletedAt: string | null;
|
|
233
|
+
tags: string[];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Tag entity
|
|
238
|
+
*/
|
|
239
|
+
export interface Tag {
|
|
240
|
+
id: number;
|
|
241
|
+
name: string;
|
|
242
|
+
usageCount: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Relationship entity
|
|
247
|
+
*/
|
|
248
|
+
export interface Relationship {
|
|
249
|
+
id: number;
|
|
250
|
+
fromEntryId: number;
|
|
251
|
+
toEntryId: number;
|
|
252
|
+
relationshipType: RelationshipType;
|
|
253
|
+
description: string | null;
|
|
254
|
+
createdAt: string;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Embedding entity for vector search
|
|
259
|
+
*/
|
|
260
|
+
export interface Embedding {
|
|
261
|
+
entryId: number;
|
|
262
|
+
embedding: Float32Array;
|
|
263
|
+
modelName: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// ============================================================================
|
|
267
|
+
// GitHub Integration Types
|
|
268
|
+
// ============================================================================
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* GitHub project information
|
|
272
|
+
*/
|
|
273
|
+
export interface GitHubProject {
|
|
274
|
+
number: number;
|
|
275
|
+
title: string;
|
|
276
|
+
url: string;
|
|
277
|
+
state: 'OPEN' | 'CLOSED';
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* GitHub issue information
|
|
282
|
+
*/
|
|
283
|
+
export interface GitHubIssue {
|
|
284
|
+
number: number;
|
|
285
|
+
title: string;
|
|
286
|
+
url: string;
|
|
287
|
+
state: 'OPEN' | 'CLOSED';
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* GitHub pull request information
|
|
292
|
+
*/
|
|
293
|
+
export interface GitHubPullRequest {
|
|
294
|
+
number: number;
|
|
295
|
+
title: string;
|
|
296
|
+
url: string;
|
|
297
|
+
state: 'OPEN' | 'CLOSED' | 'MERGED';
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* GitHub workflow run information
|
|
302
|
+
*/
|
|
303
|
+
export interface GitHubWorkflowRun {
|
|
304
|
+
id: number;
|
|
305
|
+
name: string;
|
|
306
|
+
status: 'queued' | 'in_progress' | 'completed';
|
|
307
|
+
conclusion: 'success' | 'failure' | 'cancelled' | 'skipped' | null;
|
|
308
|
+
url: string;
|
|
309
|
+
headBranch: string;
|
|
310
|
+
headSha: string;
|
|
311
|
+
createdAt: string;
|
|
312
|
+
updatedAt: string;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Auto-captured project context
|
|
317
|
+
*/
|
|
318
|
+
export interface ProjectContext {
|
|
319
|
+
repoName: string | null;
|
|
320
|
+
branch: string | null;
|
|
321
|
+
commit: string | null;
|
|
322
|
+
remoteUrl: string | null;
|
|
323
|
+
projects: GitHubProject[];
|
|
324
|
+
issues: GitHubIssue[];
|
|
325
|
+
pullRequests: GitHubPullRequest[];
|
|
326
|
+
workflowRuns: GitHubWorkflowRun[];
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// ============================================================================
|
|
330
|
+
// Configuration Types
|
|
331
|
+
// ============================================================================
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Server configuration
|
|
335
|
+
*/
|
|
336
|
+
export interface ServerConfig {
|
|
337
|
+
/** Path to SQLite database file */
|
|
338
|
+
dbPath: string;
|
|
339
|
+
|
|
340
|
+
/** GitHub personal access token */
|
|
341
|
+
githubToken?: string;
|
|
342
|
+
|
|
343
|
+
/** GitHub organization token (for org projects) */
|
|
344
|
+
githubOrgToken?: string;
|
|
345
|
+
|
|
346
|
+
/** Default organization name */
|
|
347
|
+
defaultOrg?: string;
|
|
348
|
+
|
|
349
|
+
/** Tool filter string */
|
|
350
|
+
toolFilter?: string;
|
|
351
|
+
|
|
352
|
+
/** Enable semantic search */
|
|
353
|
+
enableSemanticSearch: boolean;
|
|
354
|
+
|
|
355
|
+
/** Sentence transformer model name */
|
|
356
|
+
modelName: string;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Default configuration values
|
|
361
|
+
*/
|
|
362
|
+
export const DEFAULT_CONFIG: Partial<ServerConfig> = {
|
|
363
|
+
dbPath: './memory_journal.db',
|
|
364
|
+
enableSemanticSearch: true,
|
|
365
|
+
modelName: 'all-MiniLM-L6-v2',
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// ============================================================================
|
|
369
|
+
// Backup Types
|
|
370
|
+
// ============================================================================
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Backup file information
|
|
374
|
+
*/
|
|
375
|
+
export interface BackupInfo {
|
|
376
|
+
/** Backup filename */
|
|
377
|
+
filename: string;
|
|
378
|
+
|
|
379
|
+
/** Full path to backup file */
|
|
380
|
+
path: string;
|
|
381
|
+
|
|
382
|
+
/** File size in bytes */
|
|
383
|
+
sizeBytes: number;
|
|
384
|
+
|
|
385
|
+
/** Backup creation time (ISO 8601) */
|
|
386
|
+
createdAt: string;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// ============================================================================
|
|
390
|
+
// Health Status Types
|
|
391
|
+
// ============================================================================
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Server health and diagnostics status
|
|
395
|
+
*/
|
|
396
|
+
export interface HealthStatus {
|
|
397
|
+
/** Database statistics */
|
|
398
|
+
database: {
|
|
399
|
+
path: string;
|
|
400
|
+
sizeBytes: number;
|
|
401
|
+
entryCount: number;
|
|
402
|
+
deletedEntryCount: number;
|
|
403
|
+
relationshipCount: number;
|
|
404
|
+
tagCount: number;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
/** Backup information */
|
|
408
|
+
backups: {
|
|
409
|
+
directory: string;
|
|
410
|
+
count: number;
|
|
411
|
+
lastBackup: {
|
|
412
|
+
filename: string;
|
|
413
|
+
createdAt: string;
|
|
414
|
+
sizeBytes: number;
|
|
415
|
+
} | null;
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
/** Vector search index status */
|
|
419
|
+
vectorIndex: {
|
|
420
|
+
available: boolean;
|
|
421
|
+
indexedEntries: number;
|
|
422
|
+
modelName: string | null;
|
|
423
|
+
} | null;
|
|
424
|
+
|
|
425
|
+
/** Tool filter configuration */
|
|
426
|
+
toolFilter: {
|
|
427
|
+
active: boolean;
|
|
428
|
+
enabledCount: number;
|
|
429
|
+
totalCount: number;
|
|
430
|
+
filterString: string | null;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
/** Health check timestamp (ISO 8601) */
|
|
434
|
+
timestamp: string;
|
|
435
|
+
}
|