Skip to main content
Glama

claude-mcp-server

by paybyrd
index.ts1.73 kB
import { OpenAIAgentToolkit } from '@paybyrd/ai-agent-openai'; import OpenAI from 'openai'; import type { ChatCompletionMessageParam } from 'openai/resources'; // Initialize OpenAI const openaiApiKey = process.env.OPENAI_API_KEY || 'your-openai-api-key'; if (!openaiApiKey || openaiApiKey === "your-openai-api-key") { console.error("A valid 'OPENAI_API_KEY' is required!"); process.exit(1); } const openai = new OpenAI({ apiKey: openaiApiKey, }); // Initialize the Paybyrd toolkit const paybyrdApiKey = process.env.PAYBYRD_API_KEY || 'your-paybyrd-api-key'; if (!paybyrdApiKey || paybyrdApiKey === "your-paybyrd-api-key") { console.error("A valid 'PAYBYRD_API_KEY' is required!"); process.exit(1); } const paybyrdAgentToolkit = new OpenAIAgentToolkit({ authToken: paybyrdApiKey, configuration: { actions: { paymentLinks: { create: true, }, refunds: { create: true, }, order: { read: true, }, }, }, }); (async (): Promise<void> => { let messages: ChatCompletionMessageParam[] = [ { role: 'user', content: 'Create a payment link for €50 for a yellow t-shirt purchase.', }, ]; while (true) { const completion = await openai.chat.completions.create({ model: 'gpt-4o', messages, tools: paybyrdAgentToolkit.getTools(), }); const message = completion.choices[0].message; messages.push(message); if (message.tool_calls) { const toolMessages = await Promise.all( message.tool_calls.map((tc) => paybyrdAgentToolkit.handleToolCall(tc)) ); messages = [...messages, ...toolMessages]; } else { console.log(message); break; } } })();

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/paybyrd/ai-agent-toolkit-js'

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