Skip to content

Commit 5604618

Browse files
committed
feat: Init MCP Server
1 parent 2651ed5 commit 5604618

File tree

11 files changed

+1339
-2441
lines changed

11 files changed

+1339
-2441
lines changed

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
# Ruff version.
4+
rev: v0.6.7
5+
hooks:
6+
# Run the linter.
7+
- id: ruff
8+
types_or: [ python, pyi ]
9+
args: [ --fix ]
10+
# Run the formatter.
11+
- id: ruff-format
12+
types_or: [ python, pyi ]

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

CONTRIBUTING.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
## Setting up the environment
2+
3+
create a virtual environment:
4+
5+
```shell
6+
python -m venv ./.venv
7+
```
8+
9+
active the virtual environment:
10+
11+
```shell
12+
source ./.venv/bin/activate
13+
```
14+
15+
We use [uv](https://docs.astral.sh/uv/) to manage dependencies, you can install it by:
16+
17+
```shell
18+
python -m pip install uv
19+
```
20+
21+
And then install dependencies:
22+
23+
```shell
24+
uv sync
25+
```
26+
27+
## Pre Commit
28+
29+
```shell
30+
pre-commit install
31+
```
32+
33+
## Dev MCP Server
34+
35+
start mcp dev server:
36+
37+
38+
```shell
39+
export COZE_API_TOKEN=your_coze_token
40+
mcp dev src/coze_mcp_server/server.py
41+
```
42+
43+
## Prod MCP Server
44+
45+
```shell
46+
uvx coze-mcp-server --coze-api-token=your_coze_token
47+
```

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Use a Python image with uv pre-installed
2+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv
3+
4+
# Install the project into `/app`
5+
WORKDIR /app
6+
7+
# Enable bytecode compilation
8+
ENV UV_COMPILE_BYTECODE=1
9+
10+
# Copy from the cache instead of linking since it's a mounted volume
11+
ENV UV_LINK_MODE=copy
12+
13+
# Install the project's dependencies using the lockfile and settings
14+
RUN --mount=type=cache,target=/root/.cache/uv \
15+
--mount=type=bind,source=uv.lock,target=uv.lock \
16+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
17+
uv sync --frozen --no-install-project --no-dev --no-editable
18+
19+
# Then, add the rest of the project source code and install it
20+
# Installing separately from its dependencies allows optimal layer caching
21+
ADD . /app
22+
RUN --mount=type=cache,target=/root/.cache/uv \
23+
uv sync --frozen --no-dev --no-editable
24+
25+
FROM python:3.12-slim-bookworm
26+
27+
WORKDIR /app
28+
29+
COPY --from=uv /root/.local /root/.local
30+
COPY --from=uv --chown=app:app /app/.venv /app/.venv
31+
32+
# Place executables in the environment at the front of the path
33+
ENV PATH="/app/.venv/bin:$PATH"
34+
35+
# when running the container, add --db-path and a bind mount to the host's db file
36+
ENTRYPOINT ["coze-mcp-server"]

README.md

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,118 @@
1-
# coze-mcp-server
2-
mcp server for coze
1+
# COZE MCP Server
2+
3+
A Model Context Protocol server that provides coze resource and tool.
4+
5+
### Available Tools
6+
7+
- `list_workspaces` - Get workspaces list
8+
- `list_bots` - Get bots list
9+
- `create_bot` - Create bot
10+
11+
## Installation
12+
13+
### Using uv (recommended)
14+
15+
When using [`uv`](https://docs.astral.sh/uv/) no specific installation is needed. We will
16+
use [`uvx`](https://docs.astral.sh/uv/guides/tools/) to directly run *coze-mcp-server*.
17+
18+
### Using PIP
19+
20+
Alternatively you can install `coze-mcp-server` via pip:
21+
22+
```bash
23+
pip install coze-mcp-server
24+
```
25+
26+
After installation, you can run it as a script using:
27+
28+
```bash
29+
python -m coze_mcp_server
30+
```
31+
32+
## Configuration
33+
34+
### Configure for Claude.app
35+
36+
Add to your Claude settings:
37+
38+
<details>
39+
<summary>Using uvx</summary>
40+
41+
```json
42+
"mcpServers": {
43+
"coze-mcp-server": {
44+
"command": "uvx",
45+
"args": ["coze-mcp-server"]
46+
}
47+
}
48+
```
49+
</details>
50+
51+
<details>
52+
<summary>Using docker</summary>
53+
54+
```json
55+
"mcpServers": {
56+
"coze-mcp-server": {
57+
"command": "docker",
58+
"args": ["run", "-i", "--rm", "coze-mcp-server"]
59+
}
60+
}
61+
```
62+
</details>
63+
64+
<details>
65+
<summary>Using pip installation</summary>
66+
67+
```json
68+
"mcpServers": {
69+
"coze-mcp-server": {
70+
"command": "python",
71+
"args": ["-m", "coze_mcp_server"]
72+
}
73+
}
74+
```
75+
</details>
76+
77+
### Configure for Zed
78+
79+
Add to your Zed settings.json:
80+
81+
<details>
82+
<summary>Using uvx</summary>
83+
84+
```json
85+
"context_servers": [
86+
"coze-mcp-server": {
87+
"command": "uvx",
88+
"args": ["coze-mcp-server"]
89+
}
90+
],
91+
```
92+
</details>
93+
94+
<details>
95+
<summary>Using pip installation</summary>
96+
97+
```json
98+
"context_servers": {
99+
"coze-mcp-server": {
100+
"command": "python",
101+
"args": ["-m", "coze_mcp_server"]
102+
}
103+
},
104+
```
105+
</details>
106+
107+
## Build
108+
109+
Docker build:
110+
111+
```bash
112+
cd src/coze_mcp_server
113+
docker build -t coze_mcp_server .
114+
```
115+
116+
## License
117+
118+
MIT License.

0 commit comments

Comments
 (0)