@chainlink/mcp-server
Version:
Prototype MCP Server for CLL
60 lines • 2.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchCcipLaneLatency = exports.fetchCcipMessageById = void 0;
const logger_1 = require("../../../utils/logger");
const CCIP_API_ENDPOINTS = {
baseUrl: "https://api.ccip.chain.link/v1",
/**
* Retrieve a single message by id.
* Example: /v1/message/{messageId}
*/
messageById: (messageId) => `${CCIP_API_ENDPOINTS.baseUrl}/message/${messageId}`,
/**
* Retrieve lane latency metrics between two chain selectors.
* Required params: sourceChainSelector, destChainSelector.b
* Example: /v1/lanes/latency?sourceChainSelector=...&destChainSelector=...
*/
laneLatency: (params) => {
const q = new URLSearchParams();
q.set("sourceChainSelector", String(params.sourceChainSelector));
q.set("destChainSelector", String(params.destChainSelector));
return `${CCIP_API_ENDPOINTS.baseUrl}/lanes/latency?${q.toString()}`;
},
};
/**
* Fetch CCIP messages for a lane using chain selectors.
*/
const fetchCcipMessageById = async (messageId) => {
const apiUrl = CCIP_API_ENDPOINTS.messageById(messageId);
try {
const response = await fetch(apiUrl);
if (!response.ok) {
throw new Error(`API request failed: ${response.status} ${response.statusText}`);
}
return await response.json();
}
catch (error) {
logger_1.Logger.log("error", `Failed to fetch CCIP message: ${error}`);
throw error;
}
};
exports.fetchCcipMessageById = fetchCcipMessageById;
/**
* Fetch lane latency metrics between two chains.
*/
const fetchCcipLaneLatency = async (params) => {
const apiUrl = CCIP_API_ENDPOINTS.laneLatency(params);
try {
const response = await fetch(apiUrl);
if (!response.ok) {
throw new Error(`API request failed: ${response.status} ${response.statusText}`);
}
return await response.json();
}
catch (error) {
logger_1.Logger.log("error", `Failed to fetch CCIP lane latency: ${error}`);
throw error;
}
};
exports.fetchCcipLaneLatency = fetchCcipLaneLatency;
//# sourceMappingURL=api.js.map