# MCP Market — Agent Integration Guide

> **You are an AI Agent.** Follow these steps to connect to MCP Market and access a marketplace of MCP Servers.

## What is MCP Market?

MCP Market is an app store for AI Agents. It hosts MCP (Model Context Protocol) Servers that you can search, browse, and invoke. Each server exposes tools you can call. You need an API key and points to invoke servers.

**Base URL:** `https://www.agentmcp.shop`

---

## Step 1: Register

Register to get your API key and **2,000 free points**.

```bash
curl -X POST https://www.agentmcp.shop/api/auth/register \
  -H "Content-Type: application/json"
```

Response:
```json
{
  "agentId": "agent_xxx",
  "apiKey": "mk_xxxxxxxxxxxx",
  "balance": 2000
}
```

**Save your `apiKey`.** You'll need it for all authenticated requests.

---

## Step 2: Connect via MCP Protocol (Recommended)

MCP Market is itself an MCP Server. Add it to your MCP configuration:

```json
{
  "mcpServers": {
    "mcp-market": {
      "url": "https://www.agentmcp.shop/api/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}
```

Replace `YOUR_API_KEY` with the key from Step 1.

Once connected, you have access to these MCP tools:

| Tool | Description |
|------|-------------|
| `mcp_market_search` | Search servers by keyword, category, or sort order |
| `mcp_market_get_server` | Get server details, tool list, and ratings |
| `mcp_market_invoke` | Invoke a tool on a server (costs points) |

---

## Step 3: Browse Servers

Use the MCP tools or REST API to find servers.

**Via MCP tool:**
```
mcp_market_search({ query: "data analysis", category: "data-analysis", sort: "rating" })
```

**Via REST API:**
```bash
curl "https://www.agentmcp.shop/api/servers/search?q=data+analysis&sort=rating"
```

**Get server details:**
```bash
curl https://www.agentmcp.shop/api/servers/SERVER_ID
```

---

## Step 4: Invoke a Server

Call a tool on any server. This costs points based on the server's token price.

**Via MCP tool:**
```
mcp_market_invoke({ serverId: "SERVER_ID", tool: "tool_name", arguments: { ... } })
```

**Via REST API:**
```bash
curl -X POST https://www.agentmcp.shop/api/servers/SERVER_ID/invoke \
  -H "Authorization: Bearer mk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"tool": "tool_name", "arguments": {"input": "hello"}}'
```

---

## Step 5: Check Your Balance

```bash
curl https://www.agentmcp.shop/api/agent/balance \
  -H "Authorization: Bearer mk_your_api_key"
```

**Get more points:**
- Claim daily login bonus: `POST /api/auth/login` (+1,000 points/day)
- Recharge at `/agent/dashboard` (web)

---

## Machine Discovery

Discover MCP Market programmatically:

```bash
curl https://www.agentmcp.shop/.well-known/mcp-market.json
```

This returns endpoint URL, capabilities, auth info, and available tools.

---

## Quick Reference

| Resource | URL |
|----------|-----|
| MCP Endpoint | `https://www.agentmcp.shop/api/mcp` |
| Register | `POST /api/auth/register` |
| Search Servers | `GET /api/servers/search?q=&category=&sort=` |
| Server Detail | `GET /api/servers/:id` |
| Invoke Tool | `POST /api/servers/:id/invoke` |
| Rate Server | `POST /api/servers/:id/rate` |
| Balance | `GET /api/agent/balance` |
| Bills | `GET /api/agent/bills` |
| Discovery | `GET /.well-known/mcp-market.json` |
| Web Dashboard | `https://www.agentmcp.shop/agent/dashboard` |
| Docs | `https://www.agentmcp.shop/docs` |

---

## Categories

Available server categories:
- `data-analysis` — Data processing, analytics, visualization
- `code-generation` — Code generation, review, refactoring
- `file-processing` — File conversion, parsing, manipulation
- `knowledge-base` — Knowledge retrieval, RAG, search

---

## Points System

| Action | Points |
|--------|--------|
| Registration bonus | +2,000 |
| Daily login | +1,000 |
| Invoke server | Varies per server |
| Max balance cap | 100,000 |

---

## Need Help?

- Web UI: https://www.agentmcp.shop
- Docs: https://www.agentmcp.shop/docs
- Browse: https://www.agentmcp.shop/servers
