opik-mcp 0.1.0 → 0.1.2
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/build/cli.js +2 -6
- package/package.json +1 -1
- package/build/mcp-server.js +0 -96
package/build/cli.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import yargs from 'yargs';
|
|
3
3
|
import { hideBin } from 'yargs/helpers';
|
|
4
|
-
import { main } from './index.js';
|
|
5
4
|
import configImport from './config.js';
|
|
6
5
|
// Parse command line arguments
|
|
7
6
|
const argv = yargs(hideBin(process.argv))
|
|
@@ -29,8 +28,5 @@ configImport.transport = argv.transport;
|
|
|
29
28
|
if (argv.transport === 'sse') {
|
|
30
29
|
configImport.ssePort = argv.port;
|
|
31
30
|
}
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
console.error(`Fatal error: ${error}`);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
});
|
|
31
|
+
// Import and start the server (index.js will handle the main() call)
|
|
32
|
+
import './index.js';
|
package/package.json
CHANGED
package/build/mcp-server.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
// Import configuration
|
|
4
|
-
import configImport from './config.js';
|
|
5
|
-
const config = configImport;
|
|
6
|
-
// Setup file-based logging
|
|
7
|
-
const logFile = '/tmp/opik-mcp.log';
|
|
8
|
-
// Define logging functions
|
|
9
|
-
function logToFile(message) {
|
|
10
|
-
try {
|
|
11
|
-
const timestamp = new Date().toISOString();
|
|
12
|
-
fs.appendFileSync(logFile, `[${timestamp}] ${message}\n`);
|
|
13
|
-
}
|
|
14
|
-
catch (error) {
|
|
15
|
-
// Silently fail if we can't write to the log file
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Create a configured MCP server instance
|
|
20
|
-
* This function is used by both the CLI and the original index.ts
|
|
21
|
-
*/
|
|
22
|
-
export function createMcpServer() {
|
|
23
|
-
logToFile('Creating MCP server');
|
|
24
|
-
// Import all the handlers and capabilities from index.js
|
|
25
|
-
// Requires a refactor of index.js to export these as separate modules
|
|
26
|
-
// For now, create a minimal configuration
|
|
27
|
-
const server = new McpServer({
|
|
28
|
-
name: config.mcpName || 'Opik MCP',
|
|
29
|
-
version: config.mcpVersion || '0.0.1',
|
|
30
|
-
}, {
|
|
31
|
-
capabilities: {
|
|
32
|
-
// Minimal capabilities for demo
|
|
33
|
-
mcp__get_server_info: {
|
|
34
|
-
name: 'get_server_info',
|
|
35
|
-
description: 'Get information about the Opik server configuration',
|
|
36
|
-
parameter_schema: {
|
|
37
|
-
type: 'object',
|
|
38
|
-
additionalProperties: false,
|
|
39
|
-
properties: {
|
|
40
|
-
random_string: {
|
|
41
|
-
type: 'string',
|
|
42
|
-
description: 'Dummy parameter for no-parameter tools',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
handler: async () => {
|
|
47
|
-
return {
|
|
48
|
-
content: [
|
|
49
|
-
{
|
|
50
|
-
type: 'text',
|
|
51
|
-
text: `# Opik MCP Server
|
|
52
|
-
|
|
53
|
-
Server Name: ${config.mcpName || 'Opik MCP'}
|
|
54
|
-
Version: ${config.mcpVersion || '0.0.1'}
|
|
55
|
-
API Base URL: ${config.apiBaseUrl || 'Not configured'}
|
|
56
|
-
Self-hosted: ${config.isSelfHosted ? 'Yes' : 'No'}
|
|
57
|
-
Workspace: ${config.workspaceName || 'None'}
|
|
58
|
-
|
|
59
|
-
This is a minimal configuration for demo purposes.`,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
return server;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Start the MCP server with the provided transport
|
|
71
|
-
*/
|
|
72
|
-
export async function startServerWithTransport(transport) {
|
|
73
|
-
logToFile('Starting server with provided transport');
|
|
74
|
-
const server = createMcpServer();
|
|
75
|
-
// Add explicit error handlers to the transport
|
|
76
|
-
transport.onerror = error => {
|
|
77
|
-
logToFile(`Transport error: ${error.message}`);
|
|
78
|
-
console.error(`Transport error: ${error.message}`);
|
|
79
|
-
};
|
|
80
|
-
transport.onclose = () => {
|
|
81
|
-
logToFile('Transport connection closed');
|
|
82
|
-
console.log('Transport connection closed');
|
|
83
|
-
};
|
|
84
|
-
try {
|
|
85
|
-
// Connect server to transport
|
|
86
|
-
await server.connect(transport);
|
|
87
|
-
logToFile('Opik MCP Server successfully connected and running');
|
|
88
|
-
console.log('Opik MCP Server successfully connected and running');
|
|
89
|
-
return server;
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
logToFile(`Error in server connection: ${error?.message || error}`);
|
|
93
|
-
console.error(`Error in server connection: ${error?.message || error}`);
|
|
94
|
-
throw error;
|
|
95
|
-
}
|
|
96
|
-
}
|