Skip to content

Set up eslint and run --fix #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: bret/type-stripping
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'

export default neostandard({
ts: true,
ignores: [
...resolveIgnoresFromGitignore(),
],
})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to extend or customize here. This is intended as a low maintenance starter config.

598 changes: 296 additions & 302 deletions index.ts

Large diffs are not rendered by default.

114 changes: 56 additions & 58 deletions mock-client/debug-client.ts
Original file line number Diff line number Diff line change
@@ -1,110 +1,108 @@
#!/usr/bin/env node --experimental-strip-types
import { spawn } from 'child_process';
import readline from 'readline';
import { join } from 'path';
import { spawn } from 'child_process'
import readline from 'readline'
import { join } from 'path'

// Simple JSON-RPC client for testing MCP server
class SimpleJSONRPCClient {
private process: any;
private rl: readline.Interface;
private requestId = 1;
private pendingRequests = new Map();
private process: any
private rl: readline.Interface
private requestId = 1
private pendingRequests = new Map()

constructor(command: string, args: string[] = [], env: any = {}) {
constructor (command: string, args: string[] = [], env: any = {}) {
this.process = spawn(command, args, {
stdio: ['pipe', 'pipe', 'pipe'],
env: { ...process.env, ...env }
});
})

this.rl = readline.createInterface({
input: this.process.stdout,
crlfDelay: Infinity
});
})

this.rl.on('line', (line) => {
try {
const response = JSON.parse(line);
const response = JSON.parse(line)
if (response.id && this.pendingRequests.has(response.id)) {
const { resolve, reject } = this.pendingRequests.get(response.id);
this.pendingRequests.delete(response.id);
const { resolve, reject } = this.pendingRequests.get(response.id)
this.pendingRequests.delete(response.id)

if (response.error) {
reject(response.error);
reject(response.error)
} else {
resolve(response.result);
resolve(response.result)
}
} else if (response.method) {
console.log('Notification:', response);
console.log('Notification:', response)
}
} catch (e) {
console.error('Failed to parse response:', line);
console.error('Failed to parse response:', line)
}
});
})

this.process.stderr.on('data', (data: Buffer) => {
console.error('Server stderr:', data.toString());
});
console.error('Server stderr:', data.toString())
})
}

async sendRequest(method: string, params: any = {}) {
const id = this.requestId++;
async sendRequest (method: string, params: any = {}) {
const id = this.requestId++
const request = {
jsonrpc: '2.0',
id,
method,
params
};
}

return new Promise((resolve, reject) => {
this.pendingRequests.set(id, { resolve, reject });
this.process.stdin.write(JSON.stringify(request) + '\n');
});
this.pendingRequests.set(id, { resolve, reject })
this.process.stdin.write(JSON.stringify(request) + '\n')
})
}

close() {
this.rl.close();
this.process.kill();
close () {
this.rl.close()
this.process.kill()
}
}



async function main() {
const apiKey = process.env['SOCKET_API_KEY'];
async function main () {
const apiKey = process.env['SOCKET_API_KEY']
if (!apiKey) {
console.error('Error: SOCKET_API_KEY environment variable is required');
process.exit(1);
console.error('Error: SOCKET_API_KEY environment variable is required')
process.exit(1)
}

console.log('Starting MCP server debug client...');
console.log('Starting MCP server debug client...')

const serverPath = join(import.meta.dirname, '..', 'index.ts');
console.log(`Using server script: ${serverPath}`);
const serverPath = join(import.meta.dirname, '..', 'index.ts')
console.log(`Using server script: ${serverPath}`)

const client = new SimpleJSONRPCClient('node', ['--experimental-strip-types', serverPath], {
SOCKET_API_KEY: apiKey
});
})

try {
// Initialize the connection
console.log('\n1. Initializing connection...');
console.log('\n1. Initializing connection...')
const initResult = await client.sendRequest('initialize', {
protocolVersion: '0.1.0',
capabilities: {},
clientInfo: {
name: 'debug-client',
version: '1.0.0'
}
});
console.log('Initialize response:', JSON.stringify(initResult, null, 2));
})
console.log('Initialize response:', JSON.stringify(initResult, null, 2))

// List available tools
console.log('\n2. Listing available tools...');
const toolsResult = await client.sendRequest('tools/list', {});
console.log('Available tools:', JSON.stringify(toolsResult, null, 2));
console.log('\n2. Listing available tools...')
const toolsResult = await client.sendRequest('tools/list', {})
console.log('Available tools:', JSON.stringify(toolsResult, null, 2))

// Call the depscore tool
console.log('\n3. Calling depscore tool...');
console.log('\n3. Calling depscore tool...')
const depscoreResult = await client.sendRequest('tools/call', {
name: 'depscore',
arguments: {
Expand All @@ -116,11 +114,11 @@ async function main() {
{ depname: 'unknown-package', ecosystem: 'npm', version: 'unknown' }
]
}
});
console.log('Depscore result:', JSON.stringify(depscoreResult, null, 2));
})
console.log('Depscore result:', JSON.stringify(depscoreResult, null, 2))

// Test with minimal input
console.log('\n4. Testing with minimal input (default to npm)...');
console.log('\n4. Testing with minimal input (default to npm)...')
const minimalResult = await client.sendRequest('tools/call', {
name: 'depscore',
arguments: {
Expand All @@ -129,28 +127,28 @@ async function main() {
{ depname: 'typescript' }
]
}
});
console.log('Minimal input result:', JSON.stringify(minimalResult, null, 2));
})
console.log('Minimal input result:', JSON.stringify(minimalResult, null, 2))

// Test error handling
console.log('\n5. Testing error handling (empty packages)...');
console.log('\n5. Testing error handling (empty packages)...')
try {
await client.sendRequest('tools/call', {
name: 'depscore',
arguments: {
packages: []
}
});
})
} catch (error) {
console.log('Expected error:', error);
console.log('Expected error:', error)
}

console.log('\nDebug session complete!');
console.log('\nDebug session complete!')
} catch (error) {
console.error('Client error:', error);
console.error('Client error:', error)
} finally {
client.close();
client.close()
}
}

main().catch(console.error);
main().catch(console.error)
Loading