0.3.6 • Published 1 year ago

@paybyrd/ai-agent-claude v0.3.6

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Paybyrd AI Agent for Claude

Anthropic Claude integration for Paybyrd's AI Agent Toolkit.

Installation

npm install @paybyrd/ai-agent-claude

Quick Start

This package provides a server compatible with Anthropic's Model Context Protocol (MCP).

Running the Agent

You can use npx to start the agent server:

npx -y @paybyrd/ai-agent-claude

Authentication

You can authenticate using any of these methods:

  • Environment Variable: PAYBYRD_API_KEY: Your Paybyrd API key
  • Command Argument: Pass your API key directly as an argument
# With API Key
npx -y @paybyrd/ai-agent-claude YOUR_API_KEY

Full Example

import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { Anthropic } from "@anthropic-ai/sdk";

// Your Anthropic API key
const ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY;

// Your Paybyrd API Key
const PAYBYRD_API_KEY = process.env.PAYBYRD_API_KEY;

async function main() {
  // Initialize the Anthropic client
  const anthropic = new Anthropic({
    apiKey: ANTHROPIC_API_KEY,
  });

  const mcp = new Client({ name: "mcp-client-cli", version: "1.0.0" });

  // Start the server process
  const transport = new StdioClientTransport({
    command: "npx",
    args: ["-y", "@paybyrd/ai-agent-claude"],
    env: {
      PAYBYRD_API_KEY: PAYBYRD_API_KEY
    }
  });

  // Alternatively, you can pass the API key directly as an argument:
  // args: ["-y", "@paybyrd/ai-agent-claude", PAYBYRD_API_KEY],
  // env: {}

  mcp.connect(transport);

  const toolsResult = await mcp.listTools();
  const tools = toolsResult.tools.map((tool) => ({
    name: tool.name,
    description: tool.description,
    input_schema: tool.inputSchema,
  }));

  // Make a request to Claude with the tools
  const message = await anthropic.messages.create({
    model: "claude-3-5-sonnet-20241022",
    max_tokens: 1000,
    messages: [
      {
        role: "user",
        content: "Please retrieve the order '627f7c5c-b50b-412c-868f-bbae98c16b2e'"
      }
    ],
    tools: tools
  });
  
  console.log("Claude response:", message.content);
}

main().catch(error => {
  console.error('Client error:', error);
});

License

MIT

0.3.6

1 year ago

0.3.5

1 year ago

0.3.4

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.7

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago