Extend AI Toolkit MCP server

Enabling agentic spend and expense management workflows using Extend's AIs
Back to servers
Setup instructions
Provider
Extend
Release date
May 15, 2025
Stats
16 stars

The Extend AI Toolkit provides integration with Extend APIs for multiple AI frameworks, including Model Context Protocol (MCP), OpenAI, LangChain, and CrewAI. This toolkit enables AI agents to perform spend management tasks such as managing virtual cards, viewing credit cards, and handling transactions.

Installation

Install the package using pip:

pip install extend_ai_toolkit

Requirements

  • Python 3.10 or higher
  • Extend API Key (sign up at paywithextend.com)
  • Framework-specific requirements:
    • LangChain: langchain and langchain-openai packages
    • OpenAI: openai package
    • CrewAI: crewai package
    • Anthropic: anthropic package (for Claude)

Configuration

Configure the library with your Extend API credentials using either command-line arguments:

--api-key=your_api_key_here --api-secret=your_api_secret_here 

Or environment variables:

EXTEND_API_KEY=your_api_key_here
EXTEND_API_SECRET=your_api_secret_here

Available Tools

Virtual Cards

  • get_virtual_cards: Fetch virtual cards with optional filters
  • get_virtual_card_detail: Get detailed information about a specific virtual card

Credit Cards

  • get_credit_cards: List all credit cards
  • get_credit_card_detail: Get detailed information about a specific credit card

Transactions

  • get_transactions: Fetch transactions with various filters
  • get_transaction_detail: Get detailed information about a specific transaction
  • update_transaction_expense_data: Update expense-related data for a transaction

Expense Management

  • get_expense_categories: List all expense categories
  • get_expense_category: Get details of a specific expense category
  • get_expense_category_labels: Get labels for an expense category
  • create_expense_category: Create a new expense category
  • create_expense_category_label: Add a label to an expense category
  • update_expense_category: Modify an existing expense category
  • create_receipt_attachment: Upload a receipt (and optionally attach to a transaction)
  • automatch_receipts: Initiate async job to automatch uploaded receipts to transactions
  • get_automatch_status: Get the status of an automatch job
  • send_receipt_reminder: Send a reminder (via email) for a transaction missing a receipt

Using the MCP Server

Local Development

Test the Extend MCP server locally using MCP Inspector:

npx @modelcontextprotocol/inspector python extend_ai_toolkit/modelcontextprotocol/main.py --tools=all

Claude Desktop Integration

Add the MCP server to Claude Desktop by editing the configuration file:

  • MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

Add this configuration:

{
  "extend-mcp": {
    "command": "python",
    "args": [
      "-m",
      "extend_ai_toolkit.modelcontextprotocol.main",
      "--tools=all"
    ],
    "env": {
      "EXTEND_API_KEY": "apik_XXXX",
      "EXTEND_API_SECRET": "XXXXX"
    }
  }
}

For receipt attachment functionality, install the filesystem MCP server:

npm install @modelcontextprotocol/server-filesystem

Then add this to your config file:

{
  "filesystem": { 
    "command": "npx",
    "args": [
      "-y",
      "@modelcontextprotocol/server-filesystem",
      "/path/to/receipts/folder"
    ]
  }
}

Running Remotely

Run the server remotely using SSE transport:

python -m extend_ai_toolkit.modelcontextprotocol.main_sse --tools=all --api-key="apikey" --api-secret="apisecret"

Connect using the MCP terminal client:

python -m extend_ai_toolkit.modelcontextprotocol.client.mcp_client --mcp-server-host localhost --mcp-server-port 8000 --llm-provider=anthropic --llm-model=claude-3-5-sonnet-20241022

Framework Integration Examples

OpenAI Example

import os
from langchain_openai import ChatOpenAI
from extend_ai_toolkit.openai.toolkit import ExtendOpenAIToolkit
from extend_ai_toolkit.shared import Configuration, Scope, Product, Actions

# Initialize the OpenAI toolkit
extend_openai_toolkit = ExtendOpenAIToolkit.default_instance(
    api_key=os.environ.get("EXTEND_API_KEY"),
    api_secret=os.environ.get("EXTEND_API_SECRET"),
    configuration=Configuration(
        scope=[
            Scope(Product.VIRTUAL_CARDS, actions=Actions(read=True)),
            Scope(Product.CREDIT_CARDS, actions=Actions(read=True)),
            Scope(Product.TRANSACTIONS, actions=Actions(read=True)),
        ]
    )
)

# Create an agent with the tools
extend_agent = Agent(
    name="Extend Agent",
    instructions="You are an expert at integrating with Extend",
    tools=extend_openai_toolkit.get_tools()
)

LangChain Example

import os
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from extend_ai_toolkit.langchain.toolkit import ExtendLangChainToolkit
from extend_ai_toolkit.shared import Configuration, Scope, Product, Actions

# Initialize the LangChain toolkit
extend_langchain_toolkit = ExtendLangChainToolkit.default_instance(
    api_key=os.environ.get("EXTEND_API_KEY"),
    api_secret=os.environ.get("EXTEND_API_SECRET"),
    configuration=Configuration(
        scope=[
            Scope(Product.VIRTUAL_CARDS, actions=Actions(read=True)),
            Scope(Product.CREDIT_CARDS, actions=Actions(read=True)),
            Scope(Product.TRANSACTIONS, actions=Actions(read=True)),
        ]
    )
)

# Create tools for the agent
tools = extend_langchain_toolkit.get_tools()

# Create the agent executor
langgraph_agent_executor = create_react_agent(
    ChatOpenAI(model="gpt-4"),
    tools
)

CrewAI Example

import os
from extend_ai_toolkit.crewai.toolkit import ExtendCrewAIToolkit
from extend_ai_toolkit.shared import Configuration, Scope, Product, Actions

# Initialize the CrewAI toolkit
toolkit = ExtendCrewAIToolkit.default_instance(
    api_key=os.environ.get("EXTEND_API_KEY"),
    api_secret=os.environ.get("EXTEND_API_SECRET"),
    configuration=Configuration(
        scope=[
            Scope(Product.VIRTUAL_CARDS, actions=Actions(read=True)),
            Scope(Product.CREDIT_CARDS, actions=Actions(read=True)),
            Scope(Product.TRANSACTIONS, actions=Actions(read=True)),
        ]
    )
)

# Configure the LLM (using Claude)
toolkit.configure_llm(
    model="claude-3-opus-20240229",
    api_key=os.environ.get("ANTHROPIC_API_KEY")
)

# Create the Extend agent
extend_agent = toolkit.create_agent(
    role="Extend Integration Expert",
    goal="Help users manage virtual cards, view credit cards, and check transactions efficiently",
    backstory="You are an expert at integrating with Extend, with deep knowledge of virtual cards, credit cards, and transaction management.",
    verbose=True
)

# Create a task for handling user queries
query_task = toolkit.create_task(
    description="Process and respond to user queries about Extend services",
    agent=extend_agent,
    expected_output="A clear and helpful response addressing the user's query",
    async_execution=True
)

# Create a crew with the agent and task
crew = toolkit.create_crew(
    agents=[extend_agent],
    tasks=[query_task],
    verbose=True
)

# Run the crew
result = crew.kickoff()

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "extend-mcp" '{"command":"python","args":["-m","extend_ai_toolkit.modelcontextprotocol.main","--tools=all"],"env":{"EXTEND_API_KEY":"apik_XXXX","EXTEND_API_SECRET":"XXXXX"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "extend-mcp": {
            "command": "python",
            "args": [
                "-m",
                "extend_ai_toolkit.modelcontextprotocol.main",
                "--tools=all"
            ],
            "env": {
                "EXTEND_API_KEY": "apik_XXXX",
                "EXTEND_API_SECRET": "XXXXX"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "extend-mcp": {
            "command": "python",
            "args": [
                "-m",
                "extend_ai_toolkit.modelcontextprotocol.main",
                "--tools=all"
            ],
            "env": {
                "EXTEND_API_KEY": "apik_XXXX",
                "EXTEND_API_SECRET": "XXXXX"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later