MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / testCurlCommand

Function testCurlCommand

tests/snippet-validation.test.cjs:313–345  ·  view source on GitHub ↗

* Test a curl command

(snippet)

Source from the content-addressed store, hash-verified

311 * Test a curl command
312 */
313async function testCurlCommand(snippet) {
314 try {
315 // Extract and execute the curl command
316 const { stdout, stderr } = await execAsync(snippet.code, {
317 timeout: 10000,
318 shell: '/bin/bash'
319 });
320
321 // Try to parse JSON response
322 try {
323 const response = JSON.parse(stdout);
324 return {
325 success: true,
326 response,
327 rawOutput: stdout
328 };
329 } catch (e) {
330 // Not JSON, but command succeeded
331 return {
332 success: true,
333 rawOutput: stdout,
334 error: stderr
335 };
336 }
337 } catch (error) {
338 return {
339 success: false,
340 error: error.message,
341 stdout: error.stdout,
342 stderr: error.stderr
343 };
344 }
345}
346
347/**
348 * Test a bash command (npx, uvx, etc)

Callers 1

validateSnippetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected