#!/usr/bin/env node
// Test script to demonstrate actual MCP server calls and responses
// This script simulates how the MCP server would respond to various tool calls
import axios from 'axios';
const API_BASE = 'https://price-svc-utyjy373hq-uc.a.run.app';
console.log('='.repeat(80));
console.log('PRICE SERVICE MCP - TEST EXAMPLES AND REAL API CALLS');
console.log('='.repeat(80));
console.log();
// Test 1: Basic Bitcoin Price
console.log('π TEST 1: Get Current Bitcoin Price (Default Parameters)');
console.log('MCP Tool Call:');
console.log(JSON.stringify({
tool: "get_price",
arguments: {
fromSym: "BTC"
}
}, null, 2));
try {
const response1 = await axios.get(`${API_BASE}/price`, {
params: {
fromSym: "BTC",
service: "coinbase",
resolution: "1d",
toFiat: "USD",
timezone: "UTC"
}
});
console.log('\nβ
MCP Tool Response:');
console.log(JSON.stringify({
content: [{
type: "text",
text: JSON.stringify(response1.data, null, 2)
}]
}, null, 2));
} catch (error) {
console.log('\nβ Error:', error.message);
}
console.log('\n' + '='.repeat(80));
// Test 2: Ethereum with Binance
console.log('\nπ TEST 2: Get Ethereum Price from Binance');
console.log('MCP Tool Call:');
console.log(JSON.stringify({
tool: "get_price",
arguments: {
fromSym: "ETH",
service: "binance",
toFiat: "USD"
}
}, null, 2));
try {
const response2 = await axios.get(`${API_BASE}/price`, {
params: {
fromSym: "ETH",
service: "binance",
resolution: "1d",
toFiat: "USD",
timezone: "UTC"
}
});
console.log('\nβ
MCP Tool Response:');
console.log(JSON.stringify({
content: [{
type: "text",
text: JSON.stringify(response2.data, null, 2)
}]
}, null, 2));
} catch (error) {
console.log('\nβ Error:', error.message);
}
console.log('\n' + '='.repeat(80));
// Test 3: Historical Price with Timestamp
console.log('\nπ TEST 3: Get Historical Bitcoin Price (24 hours ago)');
const yesterdayTimestamp = Math.floor((Date.now() - 24 * 60 * 60 * 1000) / 1000);
console.log('MCP Tool Call:');
console.log(JSON.stringify({
tool: "get_price",
arguments: {
fromSym: "BTC",
timestampSEC: yesterdayTimestamp.toString(),
service: "coinbase"
}
}, null, 2));
try {
const response3 = await axios.get(`${API_BASE}/price`, {
params: {
fromSym: "BTC",
timestampSEC: yesterdayTimestamp.toString(),
service: "coinbase",
resolution: "1d",
toFiat: "USD",
timezone: "UTC"
}
});
console.log('\nβ
MCP Tool Response:');
console.log(JSON.stringify({
content: [{
type: "text",
text: JSON.stringify(response3.data, null, 2)
}]
}, null, 2));
} catch (error) {
console.log('\nβ Error:', error.message);
}
console.log('\n' + '='.repeat(80));
// Test 4: Different Resolution and Fiat
console.log('\nπ TEST 4: Get Solana Price in EUR with 1h Resolution');
console.log('MCP Tool Call:');
console.log(JSON.stringify({
tool: "get_price",
arguments: {
fromSym: "SOL",
service: "binance",
resolution: "1h",
toFiat: "EUR"
}
}, null, 2));
try {
const response4 = await axios.get(`${API_BASE}/price`, {
params: {
fromSym: "SOL",
service: "binance",
resolution: "1h",
toFiat: "EUR",
timezone: "UTC"
}
});
console.log('\nβ
MCP Tool Response:');
console.log(JSON.stringify({
content: [{
type: "text",
text: JSON.stringify(response4.data, null, 2)
}]
}, null, 2));
} catch (error) {
console.log('\nβ Error:', error.message);
}
console.log('\n' + '='.repeat(80));
// Test 5: Health Check
console.log('\nπ₯ TEST 5: Health Check');
console.log('MCP Tool Call:');
console.log(JSON.stringify({
tool: "health_check",
arguments: {}
}, null, 2));
try {
const healthResponse = await axios.get(`${API_BASE}/health`);
console.log('\nβ
MCP Tool Response:');
console.log(JSON.stringify({
content: [{
type: "text",
text: JSON.stringify({
status: "healthy",
priceService: healthResponse.data,
timestamp: new Date().toISOString()
}, null, 2)
}]
}, null, 2));
} catch (error) {
console.log('\nβ MCP Tool Response (Service Unavailable):');
console.log(JSON.stringify({
content: [{
type: "text",
text: JSON.stringify({
status: "unhealthy",
error: error.message,
timestamp: new Date().toISOString()
}, null, 2)
}]
}, null, 2));
}
console.log('\n' + '='.repeat(80));
// Test 6: Error Case - Invalid Symbol
console.log('\nβ TEST 6: Error Handling - Invalid Symbol');
console.log('MCP Tool Call:');
console.log(JSON.stringify({
tool: "get_price",
arguments: {
fromSym: "INVALID_SYMBOL"
}
}, null, 2));
try {
const errorResponse = await axios.get(`${API_BASE}/price`, {
params: {
fromSym: "INVALID_SYMBOL",
service: "coinbase",
resolution: "1d",
toFiat: "USD",
timezone: "UTC"
}
});
console.log('\nπ MCP Tool Response:');
console.log(JSON.stringify({
content: [{
type: "text",
text: JSON.stringify(errorResponse.data, null, 2)
}]
}, null, 2));
} catch (error) {
console.log('\nβ MCP Tool Response (Error):');
console.log(JSON.stringify({
content: [{
type: "text",
text: `Error: ${error.message}`
}]
}, null, 2));
}
console.log('\n' + '='.repeat(80));
console.log('π― All test examples completed!');
console.log('These examples show exactly how the MCP server responds to different tool calls.');
console.log('='.repeat(80));