# Upload markdown files to assistant
for md_file in Path("data/documents").glob("*.md"):
    response = assistant.upload_file(
        file_path=str(md_file.absolute()),
        timeout=None
    )
    print(f"Uploaded {md_file.name}: {response}")
```

### Step 3: Get your Pinecone Assistant MCP server URL

1. Navigate to the **Settings** tab in [Pinecone Assistant](https://app.pinecone.io/)
2. Copy the MCP URL provided

### Step 4: Register the MCP server

Register the Pinecone MCP server as a tool in your agent configuration. Replace `<your-mcp-url>` with the MCP URL you copied in Step 4.

**Using TypeScript SDK:**

You can create your [credential](/typescript-sdk/credentials/overview) using keychain, nango, or environment variables, but in this example we use environment variables.

<CodeGroup>
  ```typescript title=".env"
  PINECONE_API_KEY=<your-pinecone-api-key>
  ```

  ```typescript title="agents/documentation-agent.ts"
  import { mcpTool, subAgent, credential } from "@inkeep/agents-sdk";

  const pineconeCredential = credential({
    id: 'pinecone-credential',
    name: 'Pinecone Credential',
    type: CredentialStoreType.memory,
    credentialStoreId: 'memory-default',
    retrievalParams: {
      "key": "PINECONE_API_KEY", // where PINECONE_API_KEY is the API key for your Pinecone project
    },
  });

  const pineconeTool = mcpTool({
    id: "pinecone-documents",
    name: "pinecone_search",
    description: "Search uploaded documents and files using semantic search",
    serverUrl: "<your-mcp-url>", // From Pinecone Settings tab
  });

  const docAgent = subAgent({
    id: "doc-agent",
    name: "Documentation Assistant",
    description: "Answers questions using uploaded documents",
    prompt: `You are a documentation assistant with access to company documents and files.`,
    canUse: () => [pineconeTool],
  });
  ```
</CodeGroup>

**Using Visual Builder:**

1. **Add a Pinecone credential:**
   * Go to the **Credentials** tab in the Visual Builder
   * Click **"New credential"**
   * Select **"Bearer authentication"**
   * Enter:
     * **Name**: `Pinecone API Key` (or your preferred name)
     * **API key**: Your Pinecone API key (found in your [Pinecone dashboard](https://app.pinecone.io/))
   * Click **"Create Credential"** to save

2. **Register the MCP server:**
   * Go to the **MCP Servers** tab in the Visual Builder
   * Click **"New MCP server"**
   * Select **"Custom Server"**
   * Enter:
     * **Name**: `Pinecone Documents`
     * **URL**: Your MCP URL from Pinecone Settings tab
     * **Transport Type**: `Streamable HTTP`
     * **Credential**: Select the Pinecone credential you created
   * Click **"Create"** to save the server

3. **Add the MCP tool to your sub agent:**
   * Drag the Pinecone Documents MCP tool onto your agent canvas and connect it to the sub agent

### Step 5: Use the Pinecone Assistant MCP server in your agent

Once you have registered your MCP server as a tool and connected it to your agent, your agent can use the Pinecone Assistant tool to search and retrieve relevant content from your uploaded documents.

Ask an interesting question like, "What are the primary uses of amlodipine and atorvastatin, and how do they work in the body?"

The Pinecone tool provides a `get_context` function that retrieves relevant document snippets from your knowledge base. When your agent calls this tool, it will:

<Steps>
  <Step>
    **Search semantically**: Use vector similarity search to find the most relevant content based on the query
  </Step>

  <Step>
    **Return formatted snippets**: Each result includes:

    <ul>
      <li>
        <code>file_name</code>

        : The name of the file containing the snippet
      </li>

      <li>
        <code>pages</code>

        : The page numbers where the snippet appears (for PDFs and DOCX files)
      </li>

      <li>
        <code>content</code>

        : The actual text content of the snippet
      </li>
    </ul>
  </Step>
</Steps>

**Parameters:**

* `query` (required): The search query to retrieve context for
* `top_k` (optional): The number of context snippets to retrieve. Defaults to 15.