Skip to main content
Glama

bnbchain-mcp

Official
by bnb-chain
sp.ts1.53 kB
import { getClient } from "./client" export const getSps = async (network: "testnet" | "mainnet") => { const client = getClient(network) const sps = await client.sp.getStorageProviders() return sps } export const getAllSps = async (network: "testnet" | "mainnet") => { const sps = await getSps(network) return sps.map((sp) => { return { address: sp.operatorAddress, endpoint: sp.endpoint, name: sp.description?.moniker, status: sp.status } }) } export const selectSp = async (network: "testnet" | "mainnet") => { const finalSps = await getSps(network) if (!finalSps?.length) { throw new Error("No storage providers available") } let allActiveSps = finalSps.filter((sp) => sp.status === 0) // 0 is STATUS_IN_SERVICE if (network === "testnet") { allActiveSps = allActiveSps.filter( (sp) => sp.endpoint.includes("nodereal") || sp.endpoint.includes("bnbchain") ) } const selectIndex = Math.floor(Math.random() * allActiveSps.length) const selectedSp = allActiveSps[selectIndex] if (!selectedSp) { throw new Error("Failed to select storage provider") } const secondarySpAddresses = [ ...finalSps.slice(0, selectIndex), ...finalSps.slice(selectIndex + 1) ].map((item) => item.operatorAddress) const selectSpInfo = { id: selectedSp.id, endpoint: selectedSp.endpoint, primarySpAddress: selectedSp.operatorAddress, sealAddress: selectedSp.sealAddress, secondarySpAddresses } return selectSpInfo }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bnb-chain/bnbchain-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server