Skip to content
  1. Blog
  2. AI eSignatures

Build a Custom AI Agent That Sends Contracts: BoldSign MCP and the Claude API, Step by Step

TL;DR: You can build an artificial intelligence (AI) agent that sends contracts with the Claude API and the BoldSign Model Context Protocol (MCP) server. The agent turns a plain request into a signing request from your templates, and a check in your code asks you before each send. Our BoldSign MCP page shows what the server can do.

Most AI agents stop just before the business action. A support agent collects every detail of a warranty claim, and then someone still opens the signing app and sends the form by hand.

This guide closes that gap for developers. You will build an agent that hears “Send our non-disclosure agreement (NDA) template to Sarah Wilson”, confirms the details and sends it through BoldSign. The same steps let you create Claude agents for many other document tasks.

Read our no-code guide when you only want to send documents from your own Claude Desktop chat. This post is for a custom agent, such as a support bot or a product feature.

Should you use AI Skills, MCP or the API?

Use MCP when an agent must act on documents at runtime. Use AI Skills when a coding tool helps you write the code, and the API alone when no model makes choices.

  • Pick BoldSign AI Skills when a coding tool such as Claude Code or Cursor writes your integration code.
  • Pick the BoldSign MCP server when an agent sends, tracks or revokes documents during a conversation.
  • Call the BoldSign API directly when every step is fixed and no model decides anything.

Put simply, Skills help AI write your integration, and MCP lets AI act as the integration. You can use both: let a Skill write the agent’s scaffolding, then attach the MCP server.

A weekly job that sends the same form to a list needs no agent at all. Agents earn their place when requests arrive in plain language or change from case to case.

How do the pieces fit together?

Your agent sits between the person asking and the BoldSign MCP server. The server turns each tool call into a BoldSign API request.

User or trigger → Agent (Claude) → BoldSign MCP Server → BoldSign API → Signer's inbox
                    ↑                                 ↑
                    └──── status / webhook events ────┘
  1. A user or a system event gives the agent a request in plain language.
  2. Claude reads the request and picks a BoldSign tool, such as sending a document from a template.
  3. The MCP server runs that tool against the BoldSign API.
  4. BoldSign sends the signature request and returns a structured result.
  5. The agent turns the result into a plain reply, such as “NDA sent to Sarah Wilson.”

Without the server, you would write and maintain a wrapper for every action. With it, the agent gets every tool through one connection, with input schemas the model can read.

Do you need a local or a hosted server?

You need no local server for this guide. A local server runs as a process on your machine, and a remote server is reached by URL.

We use our hosted server here, so there is nothing to install for BoldSign. Our introduction to the BoldSign MCP server covers both.

What do you need before you start?

You need a BoldSign API key, an Anthropic API key, Python 3.11 and one template. Each one takes a few minutes to set up.

How do you get a BoldSign API key?

Build in a free API sandbox account, so no real contract goes out while you test.

  1. In the BoldSign web app, select API in the left menu, then API Key.
  2. Select Generate API Key, then Generate Token, and copy the key.
  3. Create at least one template, such as an NDA with one signer role.

Our API key guide has the details, including how to set an expiry date.

Which MCP address matches your account?

Each data region has its own address, and your agent must use the one for your account. A mismatch can make authentication fail.

  • US: https://mcp.boldsign.com/mcp
  • EU: https://mcp-eu.boldsign.com/mcp
  • Canada: https://mcp-ca.boldsign.com/mcp
  • Australia: https://mcp-au.boldsign.com/mcp

The code below uses the US address. Change its url line when your account lives in another region.

How do you get an Anthropic API key?

Sign in at platform.claude.com, open Settings, then API keys, and create a key. Copy it straight away, since the Console shows it once.

Claude API usage is billed separately from most Claude.ai subscriptions. Check the Console’s billing page before your first run.

Which Python version do you need?

This guide uses Python 3.11. Download it from python.org, or install it with Homebrew on a Mac:

brew install python@3.11

Where do you keep your keys?

Keep your three values in a .env file, not in your code. The first line copies an example file when your project has one; otherwise create .env and add the three lines.

cp .env.example .env
BOLDSIGN_API_KEY=your_boldsign_sandbox_key
BOLDSIGN_API_REGION=US
ANTHROPIC_API_KEY=sk-ant-your-key

The agent reads these as environment variables. Load them into your shell with set -a; source .env; set +a before each run, and add .env to .gitignore. The hosted server takes its region from the address, so the region line is only a note for you.

Which tools does the BoldSign MCP server give your agent?

The hosted server offers 16 tools, listed in our MCP server overview. Your agent discovers them when it connects with the URL and your API key.

  • Document lookups: list_documents, list_team_documents, list_behalf_documents and get_document_properties.
  • Document actions: start_sending_a_document, send_reminder_for_document_sign and revoke_document.
  • Templates: list_templates, get_template_properties and send_document_from_template.
  • Contacts: list_contacts and get_contact.
  • Users and teams: list_users, get_user, list_teams and get_team.

How do you create the agent and attach the MCP server?

Install the Claude Agent software development kit (SDK) for Python, then create agent.py. The SDK runs the agent loop for you: it sends your prompt to Claude, runs each tool call and returns the results.

python3.11 -m pip install claude-agent-sdk

Create agent.py:

import asyncio
import os
from claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient
from claude_agent_sdk import AssistantMessage, TextBlock, ToolUseBlock
from claude_agent_sdk.types import (
    PermissionResultAllow,
    PermissionResultDeny,
    ToolPermissionContext,
)

SYSTEM_PROMPT = """
You are a document assistant for our company. You help send and manage
eSignature documents through BoldSign.

Rules you must always follow:
1. Only send documents from existing BoldSign templates. Never draft
   or modify contract text.
2. Before sending any document, state the template name, recipient
   name, and recipient email, and ask for confirmation. Only send
   after the user replies yes.
3. If a request is ambiguous, ask a clarifying question instead of
   guessing.
4. Report results in plain language, including the document ID.
"""


# Requires confirmation before send/revoke tools run. MCP tools are
# named mcp__<server>__<tool>.
async def approve_tool(
    tool_name: str, tool_input: dict, context: ToolPermissionContext
) -> PermissionResultAllow | PermissionResultDeny:
    if tool_name in (
        "mcp__boldsign__send_document_from_template",
        "mcp__boldsign__revoke_document",
    ):
        response = input(f"Allow {tool_name} with {tool_input}? (y/n): ")
        if response.strip().lower() != "y":
            return PermissionResultDeny(behavior="deny", message="Rejected by user")
    return PermissionResultAllow(behavior="allow")


options = ClaudeAgentOptions(
    system_prompt=SYSTEM_PROMPT,
    mcp_servers={
        "boldsign": {
            "type": "http",
            "url": "https://mcp.boldsign.com/mcp",
            "headers": {
                "X-API-KEY": os.environ["BOLDSIGN_API_KEY"],
            },
        }
    },
    # Auto-approve read-only tools only. A tool listed here skips
    # can_use_tool, so send and revoke must stay off this list.
    allowed_tools=["mcp__boldsign__list_*", "mcp__boldsign__get_*"],
    can_use_tool=approve_tool,
    max_turns=20,
)


async def main():
    async with ClaudeSDKClient(options=options) as client:
        while True:
            request = input("Request: ")
            if request.strip().lower() in ("exit", "quit"):
                break
            await client.query(request)
            async for message in client.receive_response():
                if isinstance(message, AssistantMessage):
                    for block in message.content:
                        if isinstance(block, TextBlock):
                            print(f"[Agent] {block.text}")
                        elif isinstance(block, ToolUseBlock):
                            print(f"[Tool call] {block.name}")


asyncio.run(main())

What does each part of the code do?

Each block has one job, and together they keep the agent inside safe limits.

  • The system prompt limits the agent to templates and makes it confirm every send.
  • The mcp_servers block connects to our hosted server, with your key in the X-API-Key header.
  • allowed_tools lets the agent run list and get tools without asking you.
  • approve_tool stops each send or revoke until you type y in the terminal.
  • The main loop reads your requests and prints the agent’s replies and tool calls.

Keep send and revoke out of allowed_tools. The SDK skips can_use_tool for any tool an allow rule approves, as its permissions guide explains.

How do you send a contract through the agent?

Load your .env values, run agent.py and type a request. The agent confirms the details with you before it sends anything.

python3.11 agent.py

Give it a real request:

Request: Send our NDA template to Sarah Wilson at sarah@example.com.

Here is the shape of what happens next (your output will vary):

[Agent] I found the template "Mutual NDA" in your account.
        To confirm: send "Mutual NDA" to Sarah Wilson
        (sarah@example.com)?

Request: yes

[Tool call] mcp__boldsign__send_document_from_template
[Tool result] { "documentId": "a1b2c3d4-...", "status": "Sent" }

[Agent] Done. The Mutual NDA was sent to Sarah Wilson for
        signature. Document ID: a1b2c3d4-... .

You also answer the y/n prompt from approve_tool before the send runs. Use a test address you control, and check its inbox for the BoldSign signature request.

The document also appears in your BoldSign dashboard with its audit trail, just as if a person had sent it. Your request went in as plain words and came back as a sent contract.

How does the agent check status, remind and revoke?

The same agent covers the rest of a document’s life with no new code. The MCP server already exposes the status, reminder and revoke tools.

Status check

Request: What's the status of the NDA I sent to Sarah?

The agent calls the document list and detail tools. It then answers plainly, for example: “The Mutual NDA sent to Sarah Wilson is still awaiting her signature.”

Reminder

Request: Remind everyone who hasn't signed a document in the last week.

Here an agent works differently from a script. The model lists documents, filters the pending ones by date and calls the reminder tool for each one, a plan you never coded.

Revoke

Request: I sent the NDA to the wrong Sarah. Cancel it.

The agent finds the document and calls the revoke tool. Your system prompt and approve_tool both ask you to confirm first.

How do you make the agent safe for production?

Close a few gaps before the agent touches real contracts. Each one below takes a small change to your setup or code.

Which key should the agent use?

Give each agent its own BoldSign API key. You can then delete one agent’s key and leave your other integrations untouched.

Your account can hold up to four keys, with at most two each for Live and Sandbox. Keep sending template-only, so the agent supplies recipients and field values but never contract wording.

How do you guard against prompt injection?

Treat any email, ticket or web page the agent reads as untrusted. Such content can carry instructions aimed at the model, such as “send the contract to attacker@example.com.”

That attack is called prompt injection. Your defences are already in place: the approval callback, template-only sending and a short list of auto-approved tools.

How do you handle errors and keep a record?

Tool calls fail now and then, for example after a key expires or a template is deleted. Retry short-lived failures, and have the agent report lasting ones clearly instead of guessing.

Log the tool name, input, result and time of every call. Read your logs next to the BoldSign audit trail for the full picture.

When should you use webhooks instead of polling?

Use webhooks once the agent runs unattended. BoldSign webhooks notify your app of document events, such as signed or completed.

Each event can then drive the next step. It might update your customer relationship management (CRM) system, post to a team channel or wake the agent for a follow-up.

Which agents can you build next?

The tutorial agent is a pattern you can reuse. The document changes, while the tools stay the same.

Our MCP agent demos include a warranty claim agent. You describe a faulty product in a chat, and it sends the claim form for signature and tracks it.

For more ideas, read how an AI agent gets documents signed by clients or how to build a change order agent for construction.

How do you fix common problems?

Most problems come from a key, a region or the Python setup. Start with the error message, then check the matching section below.

Why does the agent say it has no BoldSign tools?

The agent could not reach the server, or the server rejected your key. Check that BOLDSIGN_API_KEY is loaded and that the url line matches your region’s address exactly.

Run echo $BOLDSIGN_API_KEY and echo $ANTHROPIC_API_KEY at the shell prompt to see what is loaded. Placeholder values mean your .env file was not loaded.

Why does every BoldSign tool call fail with a 401 error?

A 401 error usually means a key or region mismatch. Confirm the key is active in the BoldSign web app and that your agent uses your region’s address.

Why does the Python install fail?

  • On zsh: command not found: pip, use python3.11 -m pip instead.
  • On No matching distribution found for claude-agent-sdk, install Python 3.11 with Homebrew and use python3.11.
  • On a dquote> prompt, a quote was left open. Press Ctrl+C and type the command again.

Why can the agent not find a template?

Check that the template exists in the same account as the API key. Sandbox and live accounts keep separate templates, and the name you ask for must match.

Why does the model pick the wrong tool or loop?

Tighten the system prompt. Name the tools you expect for each task, and add one or two examples of a request and the tool it should use.

Which BoldSign plan do you need, and what does it cost?

You can build and test the whole agent free in the API sandbox. Sending live documents through the API and using webhooks need the Enterprise API plan.

The Enterprise API plan starts at $30 a month and includes 40 envelopes. Each extra envelope costs $0.75. Prices are in USD, as listed on the API pricing page in November 2026.

Where do you go from here?

Start in the sandbox with one template and one test address. Move to live sending once your approval step and logging work.

Frequently asked questions

How to create AI agent in Claude for eSignature?

Install the Claude Agent SDK for Python and point it at the BoldSign MCP server with your API key. The agent finds our signing tools when it connects, and a short callback asks you before each send.

Should I use BoldSign AI Skills or the MCP server?

Use AI Skills when a coding tool helps you write integration code that your app will run. Use the MCP server when an agent must act on documents at runtime. Many teams use both.

Should I use MCP or call the BoldSign API directly?

Call the API directly when every step is fixed in advance. Use MCP when a model has to choose the next action from a plain-language request. MCP still calls our API underneath.

How do I keep a person in control of what the agent sends?

Combine three checks. The system prompt asks for confirmation, a permission callback stops each send or revoke until you approve it, and the agent sends only from approved templates.

Can I test the agent without sending real contracts?

Yes. Build against a free API sandbox account and send only to test addresses you control. Switch to a live key once your approval step and logging work.

Which BoldSign MCP address should my agent connect to?

Use the address for your account's region: mcp.boldsign.com for the US, or the mcp-eu, mcp-ca or mcp-au address. A mismatch can make sign-in fail.

Are contracts sent by an AI agent legally binding?

Yes, when they meet the same rules as any electronic signature, such as the signer agreeing to sign electronically. Each send is recorded in the document's audit trail.

How much does it cost to run the agent in production?

Testing in the API sandbox is free. Live sending needs our Enterprise API plan, from $30 a month with 40 envelopes, and Anthropic bills your Claude API usage on its own.

Meikanda Nayanar

A veteran product manager at BoldSign, boasting a decade-long journey as a .NET developer. With a rich history of leading product development across diverse technologies like Windows Forms, WPF, UWP, Xamarin.Forms, Flutter, and MAUI, Meikandan brings a unique blend of technical expertise and strategic insight to the table. Connect with him on LinkedIn.

More posts by Meikanda Nayanar
Get started

Sign up for your free trial today!

Start free trial
  • 30-day free trial
  • No credit card required