> ## 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 CrewAI crew deliver a Word report

> Connect Doconda's MCP server to a CrewAI agent with MCPServerHTTP: the task ends with the link to the .docx and its PDF.

Install `crewai` and `mcp`, and add Doconda's remote MCP server to the agent with `MCPServerHTTP`. When the task asks for
a Word report, the agent calls `create_document` with `format: "docx"` and the crew's result is the Word file's download
link (with its PDF).

## Steps

1. Put your Doconda API key (dashboard → **API keys**) in `DOCONDA_API_KEY`, plus the key of the model CrewAI uses.
2. Install the dependencies: `uv add crewai mcp`.
3. Define the agent with the MCP server and a task whose `expected_output` is the link:

```python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
import os

from crewai import Agent, Crew, Task
from crewai.mcp import MCPServerHTTP

key = os.environ["DOCONDA_API_KEY"]

writer = Agent(
    role="Writer",
    goal="Deliver flawless documents",
    backstory="You write clear reports and contracts.",
    mcps=[MCPServerHTTP(url="https://api.eu.doconda.com/mcp", headers={"Authorization": f"Bearer {key}"}, streamable=True)],
)

task = Task(
    description="Prepare a Word report on this quarter's sales and return the link.",
    expected_output="The Word file's download link.",
    agent=writer,
)

result = Crew(agents=[writer], tasks=[task]).kickoff()
print(result)
```

In a crew with several agents, let the others research and analyse, and give the MCP server only to the agent that
writes the deliverable.

To run it locally instead of the remote server: `MCPServerStdio(command="npx", args=["-y", "@doconda/mcp"],
env={"DOCONDA_API_KEY": key})` from `crewai.mcp`.

## What you get back

The `create_document` tool returns to the agent:

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

* An editable Word file: the look lives in its styles (Normal, Heading 1…) and the layout fits the kind of document.
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).
* Links expire after 5 minutes. To keep the file, download it with the `id`: `Doconda().documents.download(id, "docx")`
  (`pip install doconda`).

## FAQ

<AccordionGroup>
  <Accordion title="Can the report use data I already have?">
    Yes. With the local server the agent uploads files from your disk with `upload_file`; with the remote one, by URL or
    as base64. Then it passes them as sources to `create_document`.
  </Accordion>

  <Accordion title="Can I give it my company's style?">
    Yes: ask for the style in the task ("dark blue headings, Lora font") or pass one of your files and ask for "our
    template's design".
  </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

* [CrewAI](/en/agents/crewai): the full guide.
* [Quickstart](/en/quickstart).


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