polydev-ai 1.4.0 → 1.4.1

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.
@@ -1,169 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // MINIMAL MCP stdio wrapper - NO stdout pollution, JSON only
4
- const fs = require('fs');
5
- const path = require('path');
6
-
7
- class MinimalStdioWrapper {
8
- constructor() {
9
- this.userToken = process.env.POLYDEV_USER_TOKEN;
10
-
11
- // Load manifest
12
- try {
13
- const manifestPath = path.join(__dirname, 'manifest.json');
14
- this.manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
15
- } catch (error) {
16
- // Use stderr for errors
17
- console.error('Failed to load manifest:', error);
18
- process.exit(1);
19
- }
20
- }
21
-
22
- async handleRequest(request) {
23
- const { method, params, id } = request;
24
-
25
- try {
26
- switch (method) {
27
- case 'initialize':
28
- return {
29
- jsonrpc: '2.0',
30
- id,
31
- result: {
32
- protocolVersion: '2024-11-05',
33
- capabilities: { tools: {} },
34
- serverInfo: {
35
- name: 'polydev-ai',
36
- version: '1.2.13'
37
- }
38
- }
39
- };
40
-
41
- case 'tools/list':
42
- const tools = this.manifest.tools.map(tool => ({
43
- name: tool.name,
44
- description: tool.description,
45
- inputSchema: tool.inputSchema
46
- }));
47
-
48
- return {
49
- jsonrpc: '2.0',
50
- id,
51
- result: { tools }
52
- };
53
-
54
- case 'tools/call':
55
- // Check token
56
- if (!this.userToken) {
57
- return {
58
- jsonrpc: '2.0',
59
- id,
60
- error: {
61
- code: -32603,
62
- message: 'POLYDEV_USER_TOKEN environment variable is required'
63
- }
64
- };
65
- }
66
-
67
- // Forward to remote server
68
- const response = await fetch('https://www.polydev.ai/api/mcp', {
69
- method: 'POST',
70
- headers: {
71
- 'Content-Type': 'application/json',
72
- 'Authorization': `Bearer ${this.userToken}`
73
- },
74
- body: JSON.stringify(request)
75
- });
76
-
77
- if (!response.ok) {
78
- const errorText = await response.text();
79
- return {
80
- jsonrpc: '2.0',
81
- id: request.id,
82
- error: {
83
- code: -32603,
84
- message: `Remote server error: ${response.status}`
85
- }
86
- };
87
- }
88
-
89
- return await response.json();
90
-
91
- default:
92
- return {
93
- jsonrpc: '2.0',
94
- id,
95
- error: {
96
- code: -32601,
97
- message: 'Method not found'
98
- }
99
- };
100
- }
101
- } catch (error) {
102
- return {
103
- jsonrpc: '2.0',
104
- id,
105
- error: {
106
- code: -32603,
107
- message: error.message
108
- }
109
- };
110
- }
111
- }
112
-
113
- async start() {
114
- // NO console.log to stdout!
115
- // Use stderr for debug messages if needed
116
- console.error('[MCP] Starting...');
117
-
118
- process.stdin.setEncoding('utf8');
119
- let buffer = '';
120
-
121
- process.stdin.on('data', async (chunk) => {
122
- buffer += chunk;
123
-
124
- const lines = buffer.split('\n');
125
- buffer = lines.pop() || '';
126
-
127
- for (const line of lines) {
128
- if (line.trim()) {
129
- try {
130
- const request = JSON.parse(line);
131
- const response = await this.handleRequest(request);
132
- // ONLY output JSON to stdout
133
- process.stdout.write(JSON.stringify(response) + '\n');
134
- } catch (error) {
135
- console.error('Failed to process request:', error);
136
- }
137
- }
138
- }
139
- });
140
-
141
- process.stdin.on('end', () => {
142
- console.error('[MCP] Shutting down...');
143
- process.exit(0);
144
- });
145
-
146
- process.on('SIGINT', () => {
147
- console.error('[MCP] SIGINT received');
148
- process.exit(0);
149
- });
150
-
151
- process.on('SIGTERM', () => {
152
- console.error('[MCP] SIGTERM received');
153
- process.exit(0);
154
- });
155
-
156
- console.error('[MCP] Ready');
157
- }
158
- }
159
-
160
- // Start the server
161
- if (require.main === module) {
162
- const wrapper = new MinimalStdioWrapper();
163
- wrapper.start().catch(error => {
164
- console.error('Failed to start:', error);
165
- process.exit(1);
166
- });
167
- }
168
-
169
- module.exports = MinimalStdioWrapper;
File without changes