# Directory Structure
```
├── .dockerignore
├── .env.example
├── .github
│ └── workflows
│ ├── python-publish.yml
│ └── python-test.yml
├── .gitignore
├── .python-version
├── .vscode
│ └── launch.json
├── debug_inspector.sh
├── docker
│ ├── docker-compose.yml
│ └── docker-README.md
├── docs
│ └── open-api-postman
│ ├── postman_collection.json
│ └── postman_environment.json
├── k8s
│ ├── k8s-configmap.yaml
│ ├── k8s-deployment.yaml
│ ├── k8s-README.md
│ └── k8s-secret.yaml
├── LICENSE
├── pyproject.toml
├── README.md
├── run_tests.sh
├── src
│ └── mcp_server
│ ├── __init__.py
│ ├── fsprojclient.py
│ ├── server.py
│ └── test_server.py
├── sse.sh
└── uv.lock
```
# Files
--------------------------------------------------------------------------------
/.python-version:
--------------------------------------------------------------------------------
```
3.10
```
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
```
# Python-generated files
__pycache__/
*.py[oc]
build/
dist/
wheels/
*.egg-info
# Virtual environments
.venv
.env
docs/open-api-postman/.DS_Store
```
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
```
SSE_SERVER_HOST=0.0.0.0
SSE_SERVER_PORT=8000
FS_PROJ_BASE_URL=https://project.feishu.cn/
FS_PROJ_PROJECT_KEY=your_project_key
FS_PROJ_USER_KEY=your_user_key
FS_PROJ_PLUGIN_ID=your_plugin_id
FS_PROJ_PLUGIN_SECRET=your_plugin_secret
```
--------------------------------------------------------------------------------
/k8s/k8s-configmap.yaml:
--------------------------------------------------------------------------------
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: mcp-feishu-proj-config
data:
SSE_SERVER_HOST: "0.0.0.0"
SSE_SERVER_PORT: "8000"
FS_PROJ_BASE_URL: "https://project.feishu.cn/"
```
--------------------------------------------------------------------------------
/src/mcp_server/__init__.py:
--------------------------------------------------------------------------------
```python
from . import server
import argparse
def main():
"""Main entry point for the package."""
parser = argparse.ArgumentParser(description='Feishu Project MCP Server')
parser.add_argument('--transport', type=str, default='stdio', help='Transport type')
args = parser.parse_args()
server.mcp.run(args.transport)
```
--------------------------------------------------------------------------------
/sse.sh:
--------------------------------------------------------------------------------
```bash
#!/bin/bash
# check if .env file exists
if [ ! -f .env ]; then
echo "Please create a .env file with the following content:"
echo "FS_PROJ_BASE_URL=https://open.feishu.cn"
echo "FS_PROJ_PROJECT_KEY=YOUR_PROJECT_KEY"
echo "FS_PROJ_USER_KEY=YOUR_USER_KEY"
echo "FS_PROJ_PLUGIN_ID=YOUR_PLUGIN_ID"
echo "FS_PROJ_PLUGIN_SECRET=YOUR_PLUGIN_SECRET"
exit 1
fi
# start sse server
echo "Starting SSE server..."
uvx ./ --transport sse
```
--------------------------------------------------------------------------------
/docker/docker-compose.yml:
--------------------------------------------------------------------------------
```yaml
version: '3'
services:
mcp-feishu-proj:
image: python:3.10-slim # 或其他包含基本shell工具的镜像
command: sh -c "pip install uv && uv tool run /app --transport sse"
volumes:
- ../:/app
env_file:
- ../.env
environment:
- SSE_SERVER_HOST=${SSE_SERVER_HOST}
- SSE_SERVER_PORT=${SSE_SERVER_PORT}
- FS_PROJ_BASE_URL=${FS_PROJ_BASE_URL}
- FS_PROJ_PROJECT_KEY=${FS_PROJ_PROJECT_KEY}
- FS_PROJ_USER_KEY=${FS_PROJ_USER_KEY}
- FS_PROJ_PLUGIN_ID=${FS_PROJ_PLUGIN_ID}
- FS_PROJ_PLUGIN_SECRET=${FS_PROJ_PLUGIN_SECRET}
ports:
- "8000:8000"
restart: unless-stopped
```
--------------------------------------------------------------------------------
/debug_inspector.sh:
--------------------------------------------------------------------------------
```bash
#!/bin/bash
# check if .env file exists
if [ ! -f .env ]; then
echo "Please create a .env file with the following content:"
echo "FS_PROJ_BASE_URL=https://open.feishu.cn"
echo "FS_PROJ_PROJECT_KEY=YOUR_PROJECT_KEY"
echo "FS_PROJ_USER_KEY=YOUR_USER_KEY"
echo "FS_PROJ_PLUGIN_ID=YOUR_PLUGIN_ID"
echo "FS_PROJ_PLUGIN_SECRET=YOUR_PLUGIN_SECRET"
exit 1
fi
# add .env file into environment
source .env
echo "FS_PROJ_BASE_URL: $FS_PROJ_BASE_URL"
echo "FS_PROJ_PROJECT_KEY: $FS_PROJ_PROJECT_KEY"
echo "FS_PROJ_USER_KEY: $FS_PROJ_USER_KEY"
echo "FS_PROJ_PLUGIN_ID: $FS_PROJ_PLUGIN_ID"
echo "FS_PROJ_PLUGIN_SECRET: $FS_PROJ_PLUGIN_SECRET"
# Execute the inspector command
npx -y @modelcontextprotocol/inspector \
-e FS_PROJ_BASE_URL="$FS_PROJ_BASE_URL" \
-e FS_PROJ_PROJECT_KEY="$FS_PROJ_PROJECT_KEY" \
-e FS_PROJ_USER_KEY="$FS_PROJ_USER_KEY" \
-e FS_PROJ_PLUGIN_ID="$FS_PROJ_PLUGIN_ID" \
-e FS_PROJ_PLUGIN_SECRET="$FS_PROJ_PLUGIN_SECRET" \
uvx ./
```
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
```json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Python File",
"type": "debugpy",
"request": "launch",
"program": "${file}"
},
{
"name": "Python Debugger: Unittest",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"purpose": ["debug-test"],
"console": "integratedTerminal",
"justMyCode": true,
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
},
{
"name": "Python Debugger: Unittest Module",
"type": "debugpy",
"request": "launch",
"module": "unittest",
"args": [
"${file}"
],
"console": "integratedTerminal",
"justMyCode": true,
"env": {
"PYTHONPATH": "${workspaceFolder}"
}
}
]
}
```
--------------------------------------------------------------------------------
/docs/open-api-postman/postman_environment.json:
--------------------------------------------------------------------------------
```json
{
"id": "782a8646-d950-4506-81f7-5377457f0494",
"name": "开放平台环境变量",
"values": [
{
"key": "project_key",
"value": "you project_key",
"enabled": true
},
{
"key": "base_url",
"value": "you base_url",
"enabled": true
},
{
"key": "plugin_id",
"value": "you plugin_id",
"type": "default",
"enabled": true
},
{
"key": "plugin_secret",
"value": "you plugin_secret",
"type": "default",
"enabled": true
},
{
"key": "cookie",
"value": "you cookie",
"type": "default",
"enabled": true
},
{
"key": "user_key",
"value": "you user_key",
"type": "default",
"enabled": true
},
{
"key": "plugin_token",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "idem_uuid",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "code",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "refresh_token",
"value": "",
"type": "default",
"enabled": true
},
{
"key": "token",
"value": "",
"type": "default",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2022-02-17T08:19:44.545Z",
"_postman_exported_using": "Postman/9.9.1"
}
```
--------------------------------------------------------------------------------
/.github/workflows/python-test.yml:
--------------------------------------------------------------------------------
```yaml
name: Python Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
runs-on: ubuntu-latest
environment:
name: unitest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install uv
uv venv
source .venv/bin/activate
if [ -f requirements.txt ]; then uv pip sync requirements.txt; fi
uv pip install -e .
- name: Set up environment variables
run: |
echo "FS_PROJ_BASE_URL=${{ vars.FS_PROJ_BASE_URL }}" >> $GITHUB_ENV
echo "FS_PROJ_PROJECT_KEY=${{ vars.FS_PROJ_PROJECT_KEY }}" >> $GITHUB_ENV
echo "FS_PROJ_USER_KEY=${{ vars.FS_PROJ_USER_KEY }}" >> $GITHUB_ENV
echo "FS_PROJ_PLUGIN_ID=${{ vars.FS_PROJ_PLUGIN_ID }}" >> $GITHUB_ENV
echo "FS_PROJ_PLUGIN_SECRET=${{ secrets.FS_PROJ_PLUGIN_SECRET }}" >> $GITHUB_ENV
- name: Run tests
run: |
source .venv/bin/activate
python -m unittest discover -s src/mcp_server -p "test_*.py"
```
--------------------------------------------------------------------------------
/k8s/k8s-deployment.yaml:
--------------------------------------------------------------------------------
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mcp-feishu-proj
labels:
app: mcp-feishu-proj
spec:
replicas: 1
selector:
matchLabels:
app: mcp-feishu-proj
template:
metadata:
labels:
app: mcp-feishu-proj
spec:
containers:
- name: mcp-feishu-proj
image: python:3.10-slim
command: ["sh", "-c", "pip install uv && uv tool run mcp-feishu-proj@latest --transport sse"]
envFrom:
- configMapRef:
name: mcp-feishu-proj-config
- secretRef:
name: mcp-feishu-proj-secret
resources:
limits:
cpu: "500m"
memory: "512Mi"
requests:
cpu: "100m"
memory: "128Mi"
# 存活探针配置
livenessProbe:
tcpSocket:
port: 8000
initialDelaySeconds: 60
periodSeconds: 15
timeoutSeconds: 5
failureThreshold: 3
# 就绪探针配置
readinessProbe:
tcpSocket:
port: 8000
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 3
successThreshold: 1
failureThreshold: 3
---
# 如果需要暴露服务,取消下面的注释
# apiVersion: v1
# kind: Service
# metadata:
# name: mcp-feishu-proj
# spec:
# selector:
# app: mcp-feishu-proj
# ports:
# - port: 8000
# targetPort: 8000
# type: ClusterIP
```
--------------------------------------------------------------------------------
/.github/workflows/python-publish.yml:
--------------------------------------------------------------------------------
```yaml
# This workflow will upload a Python Package to PyPI when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
on:
release:
types: [published]
permissions:
contents: read
jobs:
release-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Build release distributions
run: |
# NOTE: put your own distribution build steps here.
python -m pip install build
python -m build
- name: Upload distributions
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
pypi-publish:
runs-on: ubuntu-latest
needs:
- release-build
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
# Dedicated environments with protections for publishing are strongly recommended.
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
environment:
name: pypi
# OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status:
# url: https://pypi.org/p/YOURPROJECT
#
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
# ALTERNATIVE: exactly, uncomment the following line instead:
# url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }}
steps:
- name: Retrieve release distributions
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish release distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
```