Skip to main content
Glama
AWICE Logistics MCP Server

AWICE Logistics MCP Server

by HJP957547207
README.md
# AWICE Logistics MCP Server · 物流巴巴

[简体中文](README.zh-CN.md) · [Website](https://www.5688.cn) · [Open Platform](https://www.5688.cn/open) · [API documentation](https://www.5688.cn/open/docs/start)

Connect a compatible AI assistant to the **AWICE / 物流巴巴 Open Platform** using the Model Context Protocol (MCP). Search ocean freight, air freight, international express and Amazon FBA inbound rates, check shipping schedules, and resolve logistics location codes.

This is a **local stdio MCP server** built with the official Python MCP SDK and AWICE's existing signed API client. It exposes eight query tools and one documentation resource. It does not provide a hosted HTTP/SSE endpoint, create bookings, edit orders or retrieve customer order records.

## Tools

| Tool | Purpose |
| --- | --- |
| `awice_ping` | Check application authentication and connectivity without consuming credits. |
| `awice_search_freight` | Search FCL, LCL or air freight rates, with route filters and pagination. |
| `awice_search_express` | Query international express rates by destination, weight and selected provider. |
| `awice_search_fba` | Query FBA inbound freight by Amazon warehouse code and weight. |
| `awice_search_schedules` | Search port-to-port schedules by route, carrier and departure date range. |
| `awice_get_schedule` | Get details with a schedule ID returned by the same application's search. |
| `awice_lookup` | Resolve ports, airports, shipping lines, airlines and countries. |
| `awice_popular_data` | Obtain common logistics dictionaries for caching and dropdowns. |

The `awice://docs` resource contains official links, credential setup instructions and query-scope notes. It can be read without API credentials.

## Requirements

- Python 3.10 or newer and a host that supports local stdio MCP servers.
- Your own AWICE application AppKey and AppSecret from the [Open Platform console](https://www.5688.cn/user/openapi).
- An active plan or sufficient quota/credits for the selected API. Consult your console for current pricing and availability.

An MCP installation does **not** include free access to all freight data. Dictionary search can use an allowance or credits; the popular-data endpoint is intended for free common data and local caching. Live rates and schedules depend on the route, provider and service availability.

## Install from GitHub

```bash
git clone https://github.com/HJP957547207/awice-mcp-server.git
cd awice-mcp-server
python -m venv .venv
```

On macOS/Linux:

```bash
.venv/bin/python -m pip install .
```

On Windows PowerShell:

```powershell
.venv\Scripts\python.exe -m pip install .
```

## Connect your MCP host

Add a server entry using the installed environment's **absolute Python path**:

```json
{
  "mcpServers": {
    "awice-logistics": {
      "command": "/ABSOLUTE/PATH/awice-mcp-server/.venv/bin/python",
      "args": ["-m", "awice_mcp"],
      "env": {
        "AWICE_APP_KEY": "YOUR_APP_KEY",
        "AWICE_APP_SECRET": "YOUR_APP_SECRET"
      }
    }
  }
}
```

On Windows, `command` can be `C:/path/to/awice-mcp-server/.venv/Scripts/python.exe`. Configure the environment in your host's local settings or secret manager. Replace the placeholders locally; never put real keys in a public repository, marketplace description or conversation.

If your host supports `uvx`, the same server can be launched directly from its GitHub release tag, with the same two environment variables:

```json
{
  "mcpServers": {
    "awice-logistics": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/HJP957547207/awice-mcp-server@v0.1.0",
        "awice-mcp-server"
      ],
      "env": {
        "AWICE_APP_KEY": "YOUR_APP_KEY",
        "AWICE_APP_SECRET": "YOUR_APP_SECRET"
      }
    }
  }
}
```

Restart your host after saving its configuration, then start with `awice_ping`. No API requests are made during server startup or tool discovery. Credentials are required only when a query tool is called.

## Example requests

- “Find FCL rates from Shanghai to Los Angeles. Show the quotation currency, validity and separate surcharge units.”
- “Search schedules from CNSHA to BRSSZ within my requested departure dates, then inspect one returned schedule ID.”
- “Resolve the airport code for Guangzhou before searching air freight.”
- “Query FBA inbound options for ONT8 using the actual weight I provide.”

Ocean routes accept UN/LOCODEs or location names; air routes accept IATA airport codes or names. Use two-letter country codes when a name is ambiguous. Dates use `YYYY-MM-DD`; weights are kilograms and express dimensions are centimetres. Avoid broad or repeated queries when a narrower query answers the question.

## Query behaviour

- Only fixed, documented query operations are exposed. Signed requests go to `https://www.5688.cn/api`; tool arguments cannot override the destination or supply credentials.
- API requests are serialized within the server process. A rate-limit or network failure is returned without automatic retries. An uncached express query can take over 30 seconds; the request timeout is 90 seconds.
- API errors keep their code and request ID; ambiguous locations include returned candidates. Local credential values are redacted from error details.
- Quotes are data for comparison. Confirm shipment details, included services, currency, charging units, surcharges, validity and space before booking. The server does not invent missing rates or promise availability.
- Upstream text should be treated as data by the host, not as instructions to the assistant.

## Development and validation

After installation:

```bash
python -m unittest discover -s tests -v
```

The tests exercise MCP tool schemas, dispatch, input validation, error handling, signed requests against a local fixture, and stdio client/server discovery. They use dummy credentials and do not call production freight providers. Successful local protocol tests do not establish that a specific live route currently has a quote.

## Official links

- [物流巴巴 / AWICE website](https://www.5688.cn)
- [Ocean freight search](https://www.5688.cn/fcl)
- [Logistics tools](https://www.5688.cn/tools)
- [Ports](https://www.5688.cn/ports) and [shipping schedules](https://www.5688.cn/schedule)
- [Open Platform](https://www.5688.cn/open) and [API documentation](https://www.5688.cn/open/docs/start)
- [PHP, Python and Java OpenAPI SDKs](https://github.com/HJP957547207/awice-openapi-sdk)
- [Shipping preparation guides](https://github.com/HJP957547207/awice-shipping-guide)

MIT licensed. See [LICENSE](LICENSE) and [third-party notices](THIRD_PARTY_NOTICES.md).