Create spreadsheets & documents with Claude (Tool Use / MCP)
Give Claude the ability to create shareable spreadsheets and documents by defining a tool in the Anthropic Messages API (or exposing it from an MCP server). Claude decides when to call it and supplies the data; your handler runs the request and returns a link Claude can share in the conversation.
import anthropic, requests
client = anthropic.Anthropic()
tools = [{
"name": "create_spreadsheet",
"description": "Create a shareable spreadsheet and return its URL.",
"input_schema": {
"type": "object",
"properties": {
"title": {"type": "string"},
"rows": {"type": "array",
"items": {"type": "array"}},
},
"required": ["title", "rows"],
},
}]
# When Claude returns a tool_use block, run:
def create_spreadsheet(title, rows):
r = requests.post("https://openofficeai.com/api/v1/sheets",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"title": title, "sheets": [{"rows": rows}]})
return r.json()["url"]How to create a spreadsheet with Claude (Tool Use / MCP)
- 1Declare a create_spreadsheet tool with a title + rows input_schema.
- 2Pass tools to client.messages.create and watch for a tool_use block.
- 3Run the matching HTTP request to /api/v1/sheets in your handler.
- 4Return the url as a tool_result so Claude can share the link.
Why use OpenOfficeAI with Claude (Tool Use / MCP)
- Works with the Messages API tool use and with MCP servers.
- JSON Schema maps directly to the API body — minimal glue.
- Claude returns an openable link instead of a pasted table.
Frequently asked questions
Should I use tool use or build an MCP server?
For a single app, defining the tool inline in the Messages API is simplest. If you want the capability reusable across Claude Desktop and other MCP clients, wrap the same HTTP call in an MCP server tool instead.
How does the API key stay secure?
The tool runs in your code, not inside Claude. Keep the key in an environment variable and inject it when executing the tool_use — the model never receives it.
Can Claude create formatted documents too?
Yes. Add a create_document tool that posts to /api/v1/docs with a content array of headings and paragraphs, and Claude can produce reports or memos as shareable, downloadable docs.
Start creating documents with Claude (Tool Use / MCP)
Free tier includes 500 API calls per month — no card required.
Related integrations