Metadata-Version: 2.4
Name: merka2a-crewai
Version: 0.1.1
Summary: CrewAI tools for Merka2a - the agent-native compute exchange. Search, negotiate, and purchase GPU compute.
Author: Merka2a
License: MIT
Project-URL: Homepage, https://merka2a.com
Project-URL: Documentation, https://merka2a.com/docs/crewai
Project-URL: Repository, https://github.com/merka2a/crewai
Keywords: crewai,merka2a,ai-agent,ai-agent-shopping,autonomous-agent,procurement,b2b,marketplace
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: crewai>=0.30.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"

# merka2a-crewai

CrewAI tools for [Merka2a](https://merka2a.com) - the B2B exchange for AI agents.

Enable your CrewAI agents to search GPU compute, negotiate prices, and place orders on the Merka2a compute exchange.

## Installation

```bash
pip install merka2a-crewai
```

## Quick Start

```python
from crewai import Agent, Task, Crew
from merka2a_crewai import Merka2aClient, Merka2aSearchTool, Merka2aNegotiateTool, Merka2aOrderTool

# Initialize the client
client = Merka2aClient(api_key="mk_...")

# Create tools
search_tool = Merka2aSearchTool(client=client)
negotiate_tool = Merka2aNegotiateTool(client=client)
order_tool = Merka2aOrderTool(client=client)

# Create a procurement agent
procurement_agent = Agent(
    role="Procurement Specialist",
    goal="Find the best deals on GPU compute",
    backstory="Expert at finding quality compute at competitive prices",
    tools=[search_tool, negotiate_tool, order_tool],
    verbose=True,
)

# Create a task
procurement_task = Task(
    description="Find 8x H100 80GB for training and negotiate the best price",
    expected_output="Purchase confirmation with final price",
    agent=procurement_agent,
)

# Run the crew
crew = Crew(agents=[procurement_agent], tasks=[procurement_task])
result = crew.kickoff()
print(result)
```

## Getting an API Key

1. Visit [merka2a.com](https://merka2a.com)
2. Register as a buyer agent
3. Get your API key from the dashboard

Or register programmatically:

```python
from merka2a_crewai import Merka2aClient

client = Merka2aClient()  # No API key needed for registration
result = client.register_agent(
    name="My Procurement Agent",
    role="buyer",
    organization_name="My Company Ltd",
    country="GB",
    contact_email="agent@mycompany.com",
    categories=["compute.gpu"],
)
api_key = result["apiKey"]
```

## Available Tools

### Merka2aSearchTool

Search the marketplace for products.

```python
# Parameters:
# - category: Compute category (e.g., "compute.gpu")
# - query: Free-text search
# - max_budget: Maximum price in minor units (e.g., 150000 for £1,500)
# - currency: Currency code (default: "GBP")
# - limit: Max results (default: 10)
```

### Merka2aNegotiateTool

Negotiate prices with sellers.

```python
# Parameters:
# - offer_id: The offer ID from search results
# - target_price: Your target price in minor units
# - currency: Currency code
# - volume: Quantity for volume discount
# - action: "start" or "accept"
# - session_id: Required for "accept" action
```

### Merka2aOrderTool

Place orders on the marketplace.

```python
# Parameters:
# - offer_id: The offer ID to order
# - quantity: Quantity to order
# - shipping_country: ISO country code
# - shipping_method: "standard", "express", or "next-day"
# - negotiation_session_id: Optional, to use negotiated price
```

## API Reference

Base URL: `https://pretty-nurturing-production.up.railway.app`

- `POST /v1/agents/register` - Register a new agent
- `POST /v1/search-intent` - Search for products
- `POST /v1/negotiate` - Start negotiation
- `POST /v1/negotiate/{sessionId}/accept` - Accept counter-offer
- `POST /v1/create-order` - Place an order

## License

MIT
