Skip to main content
Glama
loader.ts1.96 kB
import { ProtocolBufferEnum, ProtocolBufferMessage, protocolBufferMethodForEach, } from "./Grpc/ProtocolBuffer/ProtocolBuffer.js"; import { protoLoader } from "./Grpc/ProtocolBuffer/ProtoLoader.js"; export type Service = { name: string; methods: string[] }; export type Proto = { path: string; services: Service[]; }; export type Method = { name: string; request: string; response: string; messages: ProtocolBufferMessage[]; enums: ProtocolBufferEnum[]; }; export const loader = { async loadAsync(dir: string): Promise<Proto[]> { const proto = await protoLoader.loadAsync(dir); const result: Proto[] = []; for (const p of proto) { const services: Service[] = []; for (const s of p.protocolBuffer.services) { services.push({ name: s.name, methods: s.methods.map(m => m.name), }); } result.push({ path: p.protocolBuffer.metadata.protoPath, services: services, }); } return result; }, async getMethodAsync(path: string, service: string, method: string): Promise<Method | undefined> { const proto = await protoLoader.loadAsync(path); let result: Method | undefined = undefined; protocolBufferMethodForEach( proto.map((p) => p.protocolBuffer), (p, s, m) => { if (s.name === service && m.name === method) { result = { name: method, request: m.requestMessageName, response: m.responseMessageName, messages: [...p.messages], enums: [...p.enums], }; } return result !== undefined; }, ); return result; }, };

Implementation Reference

Latest Blog Posts

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/Yuki4-dev/grpc-mcp'

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