Skip to content

feat: provide the chat of the rag by MCP #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
466bb7f
add mcp server
MelvinKl May 5, 2025
c84f25b
Merge branch 'main' into feature/mcp
a-klos May 20, 2025
1fed3b8
chore: megre
a-klos Jun 16, 2025
6d5186b
Merge branch 'main' into feature/mcp
a-klos Jun 16, 2025
02a558f
feat: update MCP server configuration and dependencies, refactor chat…
a-klos Jun 16, 2025
1483c09
fix: update .gitignore to exclude all notebook files
a-klos Jun 16, 2025
dadf160
chore: update submodules to latest main
github-actions[bot] Jun 16, 2025
80f15c8
Update Tiltfile
a-klos Jun 16, 2025
4a5ba8f
Update mcp-server/Dockerfile
a-klos Jun 16, 2025
9542222
Update mcp-server/src/dependency_container.py
a-klos Jun 16, 2025
c6d304b
feat: update version and description in pyproject.toml; refactor tran…
a-klos Jun 16, 2025
4705662
Merge branch 'feature/mcp' of github.com:stackitcloud/rag-template in…
a-klos Jun 16, 2025
58f2201
feat: update flake8 exclusions, refactor chat handling in RagMcpServe…
a-klos Jun 16, 2025
2baa80e
chore: update submodules to latest main
github-actions[bot] Jun 16, 2025
f870b08
chore: update subproject commit in rag-infrastructure
a-klos Jun 17, 2025
2c923bc
chore: update submodules to latest main
github-actions[bot] Jun 17, 2025
6fe1dcb
feat: enhance MCP server with chat functionalities, update documentat…
a-klos Jun 20, 2025
bc3ea76
chore: update subproject commit in rag-infrastructure
a-klos Jun 20, 2025
ae9a5ac
Merge branch 'feature/mcp' of github.com:stackitcloud/rag-template in…
a-klos Jun 20, 2025
a6dfb55
chore: update submodules to latest main
github-actions[bot] Jun 20, 2025
3bd1d76
feat: add build and push step for mcp-server in Makefile
a-klos Jun 20, 2025
b4dba97
Merge branch 'feature/mcp' of github.com:stackitcloud/rag-template in…
a-klos Jun 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ auth
node_modules/

**/.notebooks
**/.notebooks/*
**/todo*.md
**/mcp.json

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
38 changes: 37 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,37 @@ local_resource(
allow_parallel=True,
)

################################## build mcp image and do live update ##################################################
# NOTE: full image names should match the one in the helm chart values.yaml!
registry = "ghcr.io/stackitcloud/rag-template"
mcp_image_name = "rag-mcp"

mcp_context = "./mcp-server"
mcp_full_image_name = "%s/%s" % (registry, mcp_image_name)
docker_build(
mcp_full_image_name,
".",
build_args={
"dev": "1" if backend_debug else "0",
},
live_update=[
sync(backend_context, "/app/mcp-server"),
],
dockerfile=mcp_context + "/Dockerfile",
)

# Add linter trigger
local_resource(
"MCP server linting",
create_linter_command(mcp_context, "back"),
labels=["linting"],
auto_init=False,
trigger_mode=TRIGGER_MODE_AUTO,
allow_parallel=True,
)

########################################################################################################################
################################## build admin backend image and do live update ##############################################
################################## build admin backend image and do live update ########################################
########################################################################################################################

# NOTE: full image names should match the one in the helm chart values.yaml!
Expand Down Expand Up @@ -313,6 +342,8 @@ value_override = [
"features.minio.enabled=true",
"shared.config.tls.enabled=false",
"shared.ssl=false",
"shared.config.basicAuth.enabled=true",
"backend.mcp.enabled=true",
# ingress host names
"backend.ingress.host.name=rag.localhost",
# langfuse
Expand Down Expand Up @@ -398,6 +429,11 @@ k8s_resource(
31415,
container_port=31415,
name="Backend-Debugger",
),
port_forward(
9090,
container_port=8000,
name="MCP-Server",
)
],
labels=["backend"],
Expand Down
63 changes: 63 additions & 0 deletions mcp-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM --platform=linux/amd64 python:3.11.7-bookworm AS build

ARG dev=0
ENV POETRY_VIRTUALENVS_PATH=/app/mcp-server/.venv
ENV POETRY_VERSION=1.8.3

WORKDIR /app

RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential --no-install-recommends make && \
python3 -m venv "${POETRY_VIRTUALENVS_PATH}" \
&& $POETRY_VIRTUALENVS_PATH/bin/pip install "poetry==${POETRY_VERSION}"
ENV PATH="${POETRY_VIRTUALENVS_PATH}/bin:$PATH"


WORKDIR /app/mcp-server
COPY mcp-server/pyproject.toml mcp-server/poetry.lock ./

RUN mkdir log && chmod 700 log
RUN touch /app/mcp-server/log/logfile.log && chmod 600 /app/mcp-server/log/logfile.log

RUN poetry config virtualenvs.create false &&\
if [ "$dev" = "1" ]; then \
poetry install --no-interaction --no-ansi --no-root --with dev; \
else \
poetry install --no-interaction --no-ansi --no-root; \
fi

FROM --platform=linux/amd64 python:3.11.7-bookworm
ARG dev=0

RUN adduser --disabled-password --gecos "" --uid 65532 nonroot

ENV POETRY_VIRTUALENVS_PATH=/app/mcp-server/.venv
COPY --from=build --chown=nonroot:nonroot ${POETRY_VIRTUALENVS_PATH} ${POETRY_VIRTUALENVS_PATH}
COPY --from=build /usr/local/bin/ /usr/local/bin/
COPY --from=build /usr/bin/make /usr/bin/make
COPY --from=build /usr/local/lib/ /usr/local/lib/

WORKDIR /app/mcp-server
COPY --chown=nonroot:nonroot mcp-server .


# cleanup
RUN apt-get clean autoclean
RUN apt-get autoremove --yes

RUN if [ "$dev" = "0" ]; then \
while read -r shell; do rm -f "$shell"; done < /etc/shells; \
rm -rf /var/lib/{apt,dpkg,cache,log}/ \
else \
echo "POETRY_VIRTUALENVS_PATH=/app/mcp-server/.venv" >> /etc/environment;\
export POETRY_VIRTUALENVS_PATH=/app/mcp-server/.venv;\
export PATH="${POETRY_VIRTUALENVS_PATH}/bin:$PATH";\
fi


USER nonroot
COPY --from=build --chown=nonroot:nonroot /app/mcp-server/log /app/mcp-server/log

ENV PATH="${POETRY_VIRTUALENVS_PATH}/bin:${PATH}"

CMD [ "poetry", "run", "python", "src/main.py" ]
7 changes: 7 additions & 0 deletions mcp-server/api-generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash


docker run --user $(id -u):$(id -g) --rm -v $PWD:/local openapitools/openapi-generator-cli@sha256:b35aee2d0f6ffadadcdad9d8fc3c46e8d48360c20b5731a5f47c809d51f67a04 generate -i /local/rag-core-library/rag-core-api/openapi.yaml -g python -o /local/mcp-server/src --additional-properties=generateSourceCodeOnly=True,packageName=rag_backend_client.openapi_client
cd ./mcp-server
black .
cd ..
Loading