Initial commit: Suno MCP server with 24 tools, proxy support, and opencode skill
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
const apiKey = process.env.SUNO_API_KEY;
|
||||
if (!apiKey) {
|
||||
console.error('Usage: SUNO_API_KEY=your-key node test-real.js');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const server = spawn('node', ['dist/index.js'], {
|
||||
env: { ...process.env, SUNO_API_KEY: apiKey },
|
||||
cwd: __dirname,
|
||||
});
|
||||
|
||||
let output = '';
|
||||
let initialized = false;
|
||||
let step = 0;
|
||||
|
||||
const requests = [
|
||||
{ id: 1, name: 'suno_get_credits', args: {} },
|
||||
{ id: 2, name: 'suno_boost_style', args: { content: 'Pop, mysterious' } },
|
||||
];
|
||||
|
||||
function sendRequest(id, name, args) {
|
||||
server.stdin.write(
|
||||
JSON.stringify({
|
||||
jsonrpc: '2.0',
|
||||
id,
|
||||
method: 'tools/call',
|
||||
params: { name, arguments: args },
|
||||
}) + '\n'
|
||||
);
|
||||
}
|
||||
|
||||
server.stdout.on('data', (data) => {
|
||||
output += data.toString();
|
||||
const lines = output.split('\n');
|
||||
for (const line of lines) {
|
||||
if (!line.trim() || !line.trim().startsWith('{')) continue;
|
||||
try {
|
||||
const msg = JSON.parse(line);
|
||||
if (!initialized && msg.id === 0) {
|
||||
initialized = true;
|
||||
const req = requests[step++];
|
||||
sendRequest(req.id, req.name, req.args);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msg.id === 1) {
|
||||
console.log('\n=== suno_get_credits ===');
|
||||
console.log(JSON.stringify(msg.result, null, 2));
|
||||
const req = requests[step++];
|
||||
sendRequest(req.id, req.name, req.args);
|
||||
} else if (msg.id === 2) {
|
||||
console.log('\n=== suno_boost_style ===');
|
||||
console.log(JSON.stringify(msg.result, null, 2));
|
||||
server.kill();
|
||||
process.exit(0);
|
||||
}
|
||||
} catch (err) {
|
||||
// ignore non-json lines
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
server.stderr.on('data', (data) => {
|
||||
console.error('STDERR:', data.toString().slice(0, 500));
|
||||
});
|
||||
|
||||
server.on('error', (err) => {
|
||||
console.error('Server error:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
server.stdin.write(
|
||||
JSON.stringify({
|
||||
jsonrpc: '2.0',
|
||||
id: 0,
|
||||
method: 'initialize',
|
||||
params: {
|
||||
protocolVersion: '2024-11-05',
|
||||
capabilities: {},
|
||||
clientInfo: { name: 'test', version: '1.0' },
|
||||
},
|
||||
}) + '\n'
|
||||
);
|
||||
}, 500);
|
||||
|
||||
setTimeout(() => {
|
||||
console.error('Test timeout');
|
||||
server.kill();
|
||||
process.exit(1);
|
||||
}, 30000);
|
||||
Reference in New Issue
Block a user