Skip to content

Commit 52434dc

Browse files
YangSen-qnYangSen-qn
and
YangSen-qn
authored
add Dockerfile (#14)
Co-authored-by: YangSen-qn <[email protected]>
1 parent 0330494 commit 52434dc

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS uv
2+
3+
WORKDIR /app
4+
5+
ENV UV_COMPILE_BYTECODE=1
6+
ENV UV_LINK_MODE=copy
7+
8+
RUN --mount=type=cache,target=/root/.cache/uv \
9+
--mount=type=bind,source=uv.lock,target=uv.lock \
10+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
11+
uv sync --frozen --no-install-project --no-dev --no-editable
12+
13+
ADD . /app
14+
RUN --mount=type=cache,target=/root/.cache/uv \
15+
uv sync --frozen --no-dev --no-editable
16+
17+
FROM python:3.12-slim-bookworm
18+
19+
WORKDIR /app
20+
21+
#COPY --from=uv /root/.local /root/.local
22+
COPY --from=uv --chown=app:app /app/.venv /app/.venv
23+
24+
# Place executables in the environment at the front of the path
25+
ENV PATH="/app/.venv/bin:$PATH"
26+
27+
# when running the container, add --db-path and a bind mount to the host's db file
28+
ENTRYPOINT ["qiniu-mcp-server"]

src/mcp_server/config/config.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,13 @@ class Config:
2929

3030
def load_config() -> Config:
3131
config = Config(
32-
access_key=os.getenv(_CONFIG_ENV_KEY_ACCESS_KEY, ""),
33-
secret_key=os.getenv(_CONFIG_ENV_KEY_SECRET_KEY, ""),
34-
endpoint_url=os.getenv(_CONFIG_ENV_KEY_ENDPOINT_URL, ""),
35-
region_name=os.getenv(_CONFIG_ENV_KEY_REGION_NAME, ""),
32+
access_key=os.getenv(_CONFIG_ENV_KEY_ACCESS_KEY, "QINIU_ACCESS_KEY"),
33+
secret_key=os.getenv(_CONFIG_ENV_KEY_SECRET_KEY, "QINIU_SECRET_KEY"),
34+
endpoint_url=os.getenv(_CONFIG_ENV_KEY_ENDPOINT_URL, "QINIU_ENDPOINT_URL"),
35+
region_name=os.getenv(_CONFIG_ENV_KEY_REGION_NAME, "QINIU_REGION_NAME"),
3636
buckets=_get_configured_buckets_from_env(),
3737
)
3838

39-
if not config.access_key:
40-
logger.error("QINIU_ACCESS_KEY is not configured")
41-
raise ValueError("QINIU_ACCESS_KEY is not configured")
42-
43-
if not config.secret_key:
44-
logger.error("QINIU_SECRET_KEY is not configured")
45-
raise ValueError("QINIU_SECRET_KEY is not configured")
46-
47-
if not config.endpoint_url:
48-
logger.error("QINIU_ENDPOINT_URL is not configured")
49-
raise ValueError("QINIU_ENDPOINT_URL is not configured")
50-
51-
if not config.region_name:
52-
logger.error("QINIU_REGION_NAME is not configured")
53-
raise ValueError("QINIU_REGION_NAME is not configured")
54-
5539
logger.info(f"Configured access_key: {config.access_key}")
5640
logger.info(f"Configured endpoint_url: {config.endpoint_url}")
5741
logger.info(f"Configured region_name: {config.region_name}")

src/mcp_server/tools/tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ async def call_tool(name: str, arguments: dict) -> ToolResult:
104104
raise ValueError(f"Tool {name} not found")
105105

106106
# 工具输入参数校验
107+
# 把 None 移除否则校验不过
108+
arguments = {k: v for k, v in arguments.items() if v is not None}
107109
try:
108110
tool_entry.input_validator(arguments)
109111
except fastjsonschema.JsonSchemaException as e:

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)