Skip to content
Back to search

llamacloud-mcp

> [!CAUTION] > This repo has been archived and is no longer supported. Please see our docs for the latest on connecting your agents to LlamaParse Platform APIs.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/run-llama--llamacloud-mcp/badge.svg)](/listings/run-llama--llamacloud-mcp)

HTML

<a href="/listings/run-llama--llamacloud-mcp"><img src="/api/listings/run-llama--llamacloud-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) 2. Run `uvx llamacloud-mcp@latest --help` to see the available options. 3. Configure your MCP client to use the `llamacloud-mcp` server. You can either launch the server directly with `uvx llamacloud-mcp@latest` or use a `claude_desktop_config.json` file to connect with claude desktop.

Usage

% uvx llamacloud-mcp@latest --help
Usage: llamacloud-mcp [OPTIONS]

Options:
  --index TEXT                    Index definition in the format
                                  name:description. Can be used multiple
                                  times.
  --extract-agent TEXT            Extract agent definition in the format
                                  name:description. Can be used multiple
                                  times.
  --project-id TEXT               Project ID for LlamaCloud
  --org-id TEXT                   Organization ID for LlamaCloud
  --transport [stdio|sse|streamable-http]
                                  Transport to run the MCP server on. One of
                                  "stdio", "sse", "streamable-http".
  --api-key TEXT                  API key for LlamaCloud
  --help                          Show this message and exit.

Configure Claude Desktop

1. Install [Claude Desktop](https://claude.ai/download) 2. In the menu bar choose `Claude` -> `Settings` -> `Developer` -> `Edit Config`. This will show up a config file that you can edit in your preferred text editor. 3. Create a add the following "mcpServers" to the config file, where each `--index` is a new index tool that you define, and each `--extract-agent` is an extraction agent tool. 4. You'll want your config to look something like this (make sure to replace `$YOURPATH` with the path to the repository):

{
    "mcpServers": {
        "llama_index_docs_server": {
            "command": "uvx",
            "args": [
                "llamacloud-mcp@latest",
                "--index",
                "your-index-name:Description of your index",
                "--index",
                "your-other-index-name:Description of your other index",
                "--extract-agent",
                "extract-agent-name:Description of your extract agent",
                "--project-name",
                "<Your LlamaCloud Project Name>",
                "--org-id",
                "<Your LlamaCloud Org ID>",
                "--api-key",
                "<Your LlamaCloud API Key>"
            ]
        },
        "filesystem": {
        "command": "npx",
        "args": [
                "-y",
                "@modelcontextprotocol/server-filesystem",
                "<your directory you want filesystem tool to have access to>"
            ]
        }
    }
}

Make sure to **restart Claude Desktop** after configuring the file.

Now you're ready to query! You should see a tool icon with your server listed underneath the query box in Claude Desktop, like this:

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 189 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. > [!CAUTION]
  2. > This repo has been archived and is no longer supported. Please see [our docs](https://developers.llamaindex.ai/for-agents/) for the latest on connecting your agents to LlamaParse Platform APIs.
  3. # LlamaIndex MCP demos
  4. `llamacloud-mcp` is a tool that allows you to use LlamaCloud as an MCP server. It can be used to query LlamaCloud indexes and extract data from files.
  5. It allows for:
  6. - specifying one or more indexes to use for context retrieval.
  7. - specifying one or more extract agents to use for data extraction
  8. - configuring project and organization ids
  9. - configuring the transport to use for the MCP server (stdio, sse, streamable-http)
  10. ## Getting Started
  11. 1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/)
  12. 2. Run `uvx llamacloud-mcp@latest --help` to see the available options.
  13. 3. Configure your MCP client to use the `llamacloud-mcp` server. You can either launch the server directly with `uvx llamacloud-mcp@latest` or use a `claude_desktop_config.json` file to connect with claude desktop.
  14. ### Usage
  15. ```bash
  16. % uvx llamacloud-mcp@latest --help
  17. Usage: llamacloud-mcp [OPTIONS]
  18. Options:
  19. --index TEXT Index definition in the format
  20. name:description. Can be used multiple
  21. times.
  22. --extract-agent TEXT Extract agent definition in the format
  23. name:description. Can be used multiple
  24. times.
  25. --project-id TEXT Project ID for LlamaCloud
  26. --org-id TEXT Organization ID for LlamaCloud
  27. --transport [stdio|sse|streamable-http]
  28. Transport to run the MCP server on. One of
  29. "stdio", "sse", "streamable-http".
  30. --api-key TEXT API key for LlamaCloud
  31. --help Show this message and exit.
  32. ```
  33. ### Configure Claude Desktop
  34. 1. Install [Claude Desktop](https://claude.ai/download)
  35. 2. In the menu bar choose `Claude` -> `Settings` -> `Developer` -> `Edit Config`. This will show up a config file that you can edit in your preferred text editor.
  36. 3. Create a add the following "mcpServers" to the config file, where each `--index` is a new index tool that you define, and each `--extract-agent` is an extraction agent tool.
  37. 4. You'll want your config to look something like this (make sure to replace `$YOURPATH` with the path to the repository):
  38. ```json
  39. {
  40. "mcpServers": {
  41. "llama_index_docs_server": {
  42. "command": "uvx",
  43. "args": [
  44. "llamacloud-mcp@latest",
  45. "--index",
  46. "your-index-name:Description of your index",
  47. "--index",
  48. "your-other-index-name:Description of your other index",
  49. "--extract-agent",
  50. "extract-agent-name:Description of your extract agent",
  51. "--project-name",
  52. "<Your LlamaCloud Project Name>",
  53. "--org-id",
  54. "<Your LlamaCloud Org ID>",
  55. "--api-key",
  56. "<Your LlamaCloud API Key>"
  57. ]
  58. },
  59. "filesystem": {
  60. "command": "npx",
  61. "args": [
  62. "-y",
  63. "@modelcontextprotocol/server-filesystem",
  64. "<your directory you want filesystem tool to have access to>"
  65. ]
  66. }
  67. }
  68. }
  69. ```
  70. Make sure to **restart Claude Desktop** after configuring the file.
  71. Now you're ready to query! You should see a tool icon with your server listed underneath the query box in Claude Desktop, like this:
  72. ![](./claude.png)
  73. ## LlamaCloud as an MCP server From Scratch
  74. To provide a local MCP server that can be used by a client like Claude Desktop, you can use `mcp-server.py`. You can use this to provide a tool that will use RAG to provide Claude with up-to-the-second private information that it can use to answer questions. You can provide as many of these tools as you want.
  75. ### Set up your LlamaCloud index
  76. 1. Get a [LlamaCloud](https://cloud.llamaindex.ai/) account
  77. 2. [Create a new index](https://docs.cloud.llamaindex.ai/llamacloud/guides/ui) with any data source you want. In our case we used [Google Drive](https://docs.cloud.llamaindex.ai/llamacloud/integrations/data_sources/google_drive) and provided a subset of the LlamaIndex documentation as a source. You could also upload documents directly to the index if you just want to test it out.
  78. 3. Get an API key from the [LlamaCloud UI](https://cloud.llamaindex.ai/)
  79. ### Set up your MCP server
  80. 1. Clone this repository
  81. 2. Create a `.env` file and add two environment variables:
  82. - `LLAMA_CLOUD_API_KEY` - The API key you got in the previous step
  83. - `OPENAI_API_KEY` - An OpenAI API key. This is used to power the RAG query. You can use [any other LLM](https://docs.llamaindex.ai/en/stable/understanding/using_llms/using_llms/) if you don't want to use OpenAI.
  84. Now let's look at the code. First you instantiate an MCP server:
  85. ```python
  86. mcp = FastMCP('llama-index-server')
  87. ```
  88. Then you define your tool using the `@mcp.tool()` decorator:
  89. ```python
  90. @mcp.tool()
  91. def llama_index_documentation(query: str) -> str:
  92. """Search the llama-index documentation for the given query."""
  93. index = LlamaCloudIndex(
  94. name="mcp-demo-2",
  95. project_name="Rando project",
  96. organization_id="e793a802-cb91-4e6a-bd49-61d0ba2ac5f9",
  97. api_key=os.getenv("LLAMA_CLOUD_API_KEY"),
  98. )
  99. response = index.as_query_engine().query(query + " Be verbose and include code examples.")
  100. return str(response)
  101. ```
  102. Here our tool is called `llama_index_documentation`; it instantiates a LlamaCloud index called `mcp-demo-2` and then uses it as a query engine to answer the query, including some extra instructions in the prompt. You'll get instructions on how to set up your LlamaCloud index in the next section.
  103. Finally, you run the server:
  104. ```python
  105. if __name__ == "__main__":
  106. mcp.run(transport="stdio")
  107. ```
  108. Note the `stdio` transport, used for communicating to Claude Desktop.
  109. ## LlamaIndex as an MCP client
  110. LlamaIndex also has an MCP client integration, meaning you can turn any MCP server into a set of tools that can be used by an agent. You can see this in `mcp-client.py`, where we use the `BasicMCPClient` to connect to our local MCP server.
  111. For simplicity of demo, we are using the same MCP server we just set up above. Ordinarily, you would not use MCP to connect LlamaCloud to a LlamaIndex agent, you would use [QueryEngineTool](https://docs.llamaindex.ai/en/stable/examples/agent/openai_agent_with_query_engine/) and pass it directly to the agent.
  112. ### Set up your MCP server
  113. To provide a local MCP server that can be used by an HTTP client, we need to slightly modify `mcp-server.py` to use the `run_sse_async` method instead of `run`. You can find this in `mcp-http-server.py`.
  114. ```python
  115. mcp = FastMCP('llama-index-server',port=8000)
  116. asyncio.run(mcp.run_sse_async())
  117. ```
  118. ### Get your tools from the MCP server
  119. ```python
  120. mcp_client = BasicMCPClient("http://localhost:8000/sse")
  121. mcp_tool_spec = McpToolSpec(
  122. client=mcp_client,
  123. # Optional: Filter the tools by name
  124. # allowed_tools=["tool1", "tool2"],
  125. )
  126. tools = mcp_tool_spec.to_tool_list()
  127. ```
  128. ### Create an agent and ask a question
  129. ```python
  130. llm = OpenAI(model="gpt-4o-mini")
  131. agent = FunctionAgent(
  132. tools=tools,
  133. llm=llm,
  134. system_prompt="You are an agent that knows how to build agents in LlamaIndex.",
  135. )
  136. async def run_agent():
  137. response = await agent.run("How do I instantiate an agent in LlamaIndex?")
  138. print(response)
  139. if __name__ == "__main__":
  140. asyncio.run(run_agent())
  141. ```
  142. You're all set! You can now use the agent to answer questions from your LlamaCloud index.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.