> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doconda.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to make a LangChain agent return an Excel file

> Connect Doconda's MCP server with langchain-mcp-adapters: the agent creates an .xlsx with real formulas and returns the link.

Install `langchain-mcp-adapters` (Python) or `@langchain/mcp-adapters` (TypeScript), connect Doconda's remote MCP server
and pass its tools to `create_agent`. When you ask for a spreadsheet, the agent calls `create_document` with
`format: "xlsx"` and you get an Excel file with real formulas and its PDF, with their links.

## Steps

1. Put your Doconda API key (dashboard → **API keys**) in `DOCONDA_API_KEY` and your model provider's key (here,
   `ANTHROPIC_API_KEY`).
2. Install the dependencies.
3. Connect the server and ask for the Excel file:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  # pip install langchain-mcp-adapters "langchain[anthropic]"
  import asyncio
  import os

  from langchain.agents import create_agent
  from langchain_mcp_adapters.client import MultiServerMCPClient


  async def main():
      client = MultiServerMCPClient({
          "doconda": {
              "transport": "streamable_http",
              "url": "https://api.eu.doconda.com/mcp",
              "headers": {"Authorization": f"Bearer {os.environ['DOCONDA_API_KEY']}"},
          },
      })
      agent = create_agent("anthropic:claude-sonnet-5-5", await client.get_tools())
      result = await agent.ainvoke({"messages": [{"role": "user", "content": "Make me an Excel file with the event budget"}]})
      print(result["messages"][-1].content)


  asyncio.run(main())
  ```

  ```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  // npm install @langchain/mcp-adapters langchain @langchain/core @langchain/langgraph
  import { MultiServerMCPClient } from "@langchain/mcp-adapters"
  import { createAgent } from "langchain"

  const client = new MultiServerMCPClient({
    doconda: {
      transport: "http",
      url: "https://api.eu.doconda.com/mcp",
      headers: { Authorization: `Bearer ${process.env.DOCONDA_API_KEY}` },
    },
  })

  const agent = createAgent({ model: "anthropic:claude-sonnet-5-5", tools: await client.getTools() })
  const result = await agent.invoke({ messages: [{ role: "user", content: "Make me an Excel file with the event budget" }] })
  console.log(result.messages.at(-1)?.content)
  await client.close()
  ```
</CodeGroup>

Any model LangChain supports works. If you'd rather not use MCP, turn `doconda.tools()` into `StructuredTool` as in the
[LangGraph](/en/agents/langgraph) guide.

## What you get back

```json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
{
  "id": "doc_01JAB3…",
  "format": "xlsx",
  "status": "ready",
  "links": { "xlsx": "https://…", "pdf": "https://…" },
  "links_note": "Links expire in 5 minutes: call get_document for fresh ones."
}
```

* An Excel file with real formulas (not pasted numbers), assumptions in their own cells and no calculation errors.
* Its PDF, and `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).
* Links expire after 5 minutes; the agent gets fresh ones with `get_document`.

## FAQ

<AccordionGroup>
  <Accordion title="Can it edit an Excel file I already have?">
    Yes, with `edit_document`: it changes only what you ask and the changes use real formulas. Through the remote MCP
    server, the file is uploaded by URL or as base64.
  </Accordion>

  <Accordion title="Can I run the MCP server locally?">
    Yes: `{ transport: "stdio", command: "npx", args: ["-y", "@doconda/mcp"] }` with `DOCONDA_API_KEY` in `env`. Locally it
    can also upload files from your disk.
  </Accordion>

  <Accordion title="How much does it cost?">
    You pay per delivered document; failed ones are not charged. See [pricing](/en/guides/account#pricing).
  </Accordion>
</AccordionGroup>

## Keep reading

* [LangChain](/en/agents/langchain): the full guide.
* [Quickstart](/en/quickstart).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.