Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 3 additions & 25 deletions deployed-agents/CrewAI/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
# 🤖 Corvic MCP with CrewAI

This tutorial demonstrates how to use Corvic's MCP protocol with CrewAI to analyze video game sales data, perform content research, and write results to a markdown file.

---

## 📘 Use Case

Using a Corvic-powered agent, CrewAI identifies the top game genre by global sales, searches for relevant content using Serper, and writes the results to a file using CrewAI's file writer tool.
This tutorial demonstrates how to use Corvic's MCP HTTP Streamable protocol with CrewAI.

---

## ✅ Prerequisites

1. Deploy a Corvic agent using the parquet version of the [video game sales dataset](https://www.kaggle.com/datasets/gregorut/videogamesales).
2. Configure your Python environment with:
1. Configure your Python environment with:
- `crewai`
- `serper-dev-tool`
- `corvic-mcp`
3. Obtain your Corvic MCP endpoint and token.

---

## 🧠 Question Asked

```text
Pass the following question to the tool as is (do not convert to SQL): Group all the data by Genre and find the top titles by global sales. Provide the top 1 genre in a tabular format.
```

## 📤 Response

The output written to `results_with_content.md` includes a tabular summary of the top genre by sales and curated content recommendations (e.g., related to Action and Grand Theft Auto V).

![Result Preview](../../assets/images/output_crewai_example.png)

2. Obtain your Corvic MCP endpoint and token. Replace `YOUR-MCP-URL-HERE` with Corvic MCP endpoint and `YOUR-CORVIC-TOKEN-HERE` with token.
---

Need help? Contact [support@corvic.ai](mailto:support@corvic.ai) or visit [https://www.corvic.ai](https://www.corvic.ai).
124 changes: 52 additions & 72 deletions deployed-agents/CrewAI/crewai-integration-example.py
Original file line number Diff line number Diff line change
@@ -1,75 +1,55 @@
from crewai import Agent, Task, Crew, Process
from tools.serper import SerperDevTool
from tools.file_writer import FileWriterTool
from mcp_adapter import MCPServerAdapter

token = "YOUR-CORVIC-API-TOKEN"

serverparams = {
"url": "<YOUR_CORVIC_AI_MCP_ENDPOINT>", # Replace with your deployed agent's endpoint
"headers": {
"Authorization": f"{token}"
#!/usr/bin/env python
import warnings

from crewai import Agent, Crew, Process, Task
from crewai_tools import MCPServerAdapter

warnings.filterwarnings("ignore", category=SyntaxWarning, module="pysbd")


def run():
"""
Run the crew.
"""
token = 'YOUR-CORVIC-TOKEN-HERE'
server_params = {
"url": "YOUR-MCP-URL-HERE",
# Replace with your actual Streamable HTTP server URL
"headers": {
"Authorization": f"{token}"
},
"timeout": 6000,
"transport": "streamable-http"
}
}

with MCPServerAdapter(serverparams) as tools:
print('configuring agent')

analyst = Agent(
role='Customer service agent',
goal="Pass the following question to the tool as is (do not convert to SQL): Group all the data by Genre and find the top titles by global sales. Provide the top 1 genre in a tabular format.",
backstory='You are a customer service expert',
verbose=True,
allow_delegation=False,
tools=tools
)

content_tool = SerperDevTool()
content_researcher = Agent(
role="Content Researcher",
goal="Look for genre information in the data returned by the analyst and find relevant content for that genre. Return top 3 hits",
backstory="You are a content recommender",
tools=[content_tool],
verbose=True,
)

fw_tool = FileWriterTool()
writer = Agent(
role='Creative writer',
goal="Data from content_researcher should be written to a file named results_with_content.md in markdown format.",
backstory='You are a documentation expert',
verbose=True,
allow_delegation=False,
tools=[fw_tool]
)

print('configuring tasks')
corvic_task = Task(
description="Understand the question and provide response after using tools",
agent=analyst,
expected_output='Give a correct response'
)

content_recommender_task = Task(
description="Search and recommend content based on response from analyst",
agent=content_researcher,
expected_output="Interesting content"
)

writing_task = Task(
description="Write all the data from the content_researcher to a file",
agent=writer,
expected_output='Status of writing to file'
)

print('configuring crew')
crew = Crew(
agents=[analyst, content_researcher, writer],
tasks=[corvic_task, content_recommender_task, writing_task],
process=Process.sequential,
verbose=True
)
try:
with MCPServerAdapter(server_params) as tools:
print(f"Available tools (manual Streamable HTTP): {[tool.name for tool in tools]}")

http_agent = Agent(
role="HTTP Service Integrator",
goal="Utilize tools from a remote MCP server via Streamable HTTP.",
backstory="An AI agent adept at interacting with complex web services.",
tools=tools,
verbose=True,
)

http_task = Task(
description="What is the mpg for valiant?",
expected_output="The result of the complex data query.",
agent=http_agent,
)

http_crew = Crew(
agents=[http_agent],
tasks=[http_task],
verbose=True,
process=Process.sequential
)
"""Creates the CrewWithCorvic crew"""
result = http_crew.kickoff()
print(result)

except Exception as e:
raise Exception(f"An error occurred while running the crew: {e}")

print('running')
result = crew.kickoff()
print(result)
56 changes: 2 additions & 54 deletions deployed-agents/OpenAI/README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,11 @@
# 🎮 Corvic AI + OpenAI Integration: Structured Data Example
# 🎮 Corvic AI + OpenAI Integration Example: MCP with Streamable HTTP Protocol

This example demonstrates how to integrate Corvic AI with an OpenAI agent framework to analyze structured data from a parquet file containing video game sales information.

---

## 📘 Use Case

In this tutorial, you'll upload a parquet file containing data about video game sales and ask Corvic to provide a report.

---

## ✅ Prerequisites

1. **Download the CSV Dataset**: Obtain the video game sales data from [Kaggle](https://www.kaggle.com/datasets/gregorut/videogamesales).

2. **Convert CSV to Parquet**: Use Python to convert the CSV file to Parquet format:

```python
import pandas as pd

df = pd.read_csv("vgsales.csv")
df.to_parquet("vgsales.parquet", index=False)
```

3. **Upload to Corvic**: Follow the documentation [here](https://app.corvic.ai/docs/howToUseCorvic/pipelines#create-pipelines) to create an agent using this parquet file.

4. **Deploy the Agent**: Deploy the agent and obtain the MCP endpoint and access token.

---

## 🧠 Question Asked

```text
Group all the data by name and find the top titles by global sales.
Output the name and the total global sales in a tabular format.
```

## 📤 Response

The Corvic agent will process the parquet data and return a report including the top-performing video game titles.

| Title | Total Global Sales |
| --------------------------- | ------------------ |
| Grand Theft Auto V | 64.29 |
| Call of Duty: Black Ops | 30.99 |
| Call of Duty: Modern Warfare 3 | 30.71 |
| Call of Duty: Black Ops II | 29.59 |
| Call of Duty: Ghosts | 28.80 |
| Call of Duty: Black Ops 3 | 26.72 |
| Call of Duty: Modern Warfare 2 | 25.02 |
| Minecraft | 24.01 |
| Grand Theft Auto IV | 22.53 |
| Call of Duty: Advanced Warfare| 21.78 |
This example demonstrates how to integrate Corvic AI with an OpenAI agent framework to analyze structured data using MCP and Streamable HTTP Protocol

---

## 📄 Notes

- Ensure that the `vgsales.parquet` file is correctly formatted and uploaded to the Corvic platform.
- Replace `<MCP_ENDPOINT>` and `<YOUR_CORVIC_API_TOKEN>` with your actual endpoint and token.
- The agent is instructed to use tools exclusively for answering queries.

Expand Down
19 changes: 9 additions & 10 deletions deployed-agents/OpenAI/openai-integration-example.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from agents import Agent, Runner
from agents.mcp import MCPServerSseParams, MCPServerSse
from agents.mcp import MCPServerStreamableHttp, MCPServerStreamableHttpParams

async def run():
params = MCPServerSseParams(
url="<YOUR_CORVIC_AI_MCP_ENDPOINT>", # Replace with your deployed agent's endpoint
params = MCPServerStreamableHttpParams(
url="MCP_ENDPOINT",
# Replace with your deployed agent's endpoint
headers={
"Authorization": "<YOUR_CORVIC_API_TOKEN>" # Replace with your API token
"Authorization": "YOUR_CORVIC_API_TOKEN",
# Replace with your API token
},
timeout=500,
sse_read_timeout=500
timeout=500
)
corvic_mcp_server = MCPServerSse(name="corvic agent", params=params, client_session_timeout_seconds=500)
corvic_mcp_server = MCPServerStreamableHttp(name="corvic agent", params=params, client_session_timeout_seconds=500)
print('connecting')
await corvic_mcp_server.connect()
tools = await corvic_mcp_server.list_tools()
Expand All @@ -23,8 +24,6 @@ async def run():
mcp_servers=[corvic_mcp_server]
)
#
result = await Runner.run(agent, "Group all the data by name and find the top titles by "
"global sales. Output the name and the total global sales in a "
"tabular format.")
result = await Runner.run(agent, "YOUR QUERY HERE")
print(result.final_output)
await corvic_mcp_server.cleanup()