Skip to content

Commit dd249e9

Browse files
updated the dockerfile
2 parents 291b01d + 73ac840 commit dd249e9

File tree

3 files changed

+130
-17
lines changed

3 files changed

+130
-17
lines changed

infra/main.bicep

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,103 @@ module containerApp 'br/public:avm/res/app/container-app:0.14.2' = if (container
10821082
}
10831083
}
10841084

1085+
var containerAppMcpResourceName = 'ca-mcp-${solutionPrefix}'
1086+
module containerAppMcp 'br/public:avm/res/app/container-app:0.18.1' = if (containerAppEnabled) {
1087+
name: take('avm.res.app.container-app.${containerAppMcpResourceName}', 64)
1088+
params: {
1089+
name: containerAppMcpResourceName
1090+
tags: containerAppConfiguration.?tags ?? tags
1091+
location: containerAppConfiguration.?location ?? solutionLocation
1092+
enableTelemetry: enableTelemetry
1093+
environmentResourceId: containerAppConfiguration.?environmentResourceId ?? containerAppEnvironment.outputs.resourceId
1094+
managedIdentities: {
1095+
systemAssigned: true
1096+
userAssignedResourceIds: [userAssignedIdentity!.outputs.resourceId]
1097+
}
1098+
ingressTargetPort: containerAppConfiguration.?ingressTargetPort ?? 8000
1099+
ingressExternal: true
1100+
activeRevisionsMode: 'Single'
1101+
corsPolicy: {
1102+
allowedOrigins: [
1103+
'https://${webSiteName}.azurewebsites.net'
1104+
'http://${webSiteName}.azurewebsites.net'
1105+
]
1106+
}
1107+
// WAF aligned configuration for Scalability
1108+
scaleSettings: {
1109+
maxReplicas: containerAppConfiguration.?maxReplicas ?? 1
1110+
minReplicas: containerAppConfiguration.?minReplicas ?? 1
1111+
rules: [
1112+
{
1113+
name: 'http-scaler'
1114+
http: {
1115+
metadata: {
1116+
concurrentRequests: containerAppConfiguration.?concurrentRequests ?? '100'
1117+
}
1118+
}
1119+
}
1120+
]
1121+
}
1122+
containers: [
1123+
{
1124+
name: 'mcp'
1125+
image: 'macaemcpacrdk.azurecr.io/macae-mac-app:t7' //'${containerAppConfiguration.?containerImageRegistryDomain ?? 'biabcontainerreg.azurecr.io'}/${containerAppConfiguration.?containerImageName ?? 'macaebackend'}:${containerAppConfiguration.?containerImageTag ?? 'latest'}'
1126+
resources: {
1127+
//TODO: Make cpu and memory parameterized
1128+
cpu: containerAppConfiguration.?containerCpu ?? '2.0'
1129+
memory: containerAppConfiguration.?containerMemory ?? '4.0Gi'
1130+
}
1131+
env: [
1132+
{
1133+
name: 'MCP_HOST'
1134+
value: '0.0.0.0'
1135+
}
1136+
{
1137+
name: 'MCP_PORT'
1138+
value: '9000'
1139+
}
1140+
{
1141+
name: 'MCP_DEBUG'
1142+
value: 'false'
1143+
}
1144+
{
1145+
name: 'MCP_SERVER_NAME'
1146+
value: 'MACAE MCP Server'
1147+
}
1148+
{
1149+
name: 'MCP_ENABLE_AUTH'
1150+
value: 'true'
1151+
}
1152+
{
1153+
name: 'AZURE_TENANT_ID'
1154+
value: tenant().tenantId
1155+
}
1156+
{
1157+
name: 'AZURE_CLIENT_ID'
1158+
value: userAssignedIdentity!.outputs.clientId
1159+
}
1160+
{
1161+
name: 'AZURE_JWKS_URI'
1162+
value: 'https://login.microsoftonline.com/${tenant().tenantId}/discovery/v2.0/keys'
1163+
}
1164+
{
1165+
name: 'AZURE_ISSUER'
1166+
value: 'https://sts.windows.net/${tenant().tenantId}/'
1167+
}
1168+
{
1169+
name: 'AZURE_AUDIENCE'
1170+
value: 'api://${userAssignedIdentity!.outputs.clientId}'
1171+
}
1172+
{
1173+
name: 'DATASET_PATH'
1174+
value: './datasets'
1175+
}
1176+
]
1177+
}
1178+
]
1179+
}
1180+
}
1181+
10851182
var webServerFarmEnabled = webServerFarmConfiguration.?enabled ?? true
10861183
var webServerFarmResourceName = webServerFarmConfiguration.?name ?? 'asp-${solutionPrefix}'
10871184

src/mcp_server/Dockerfile

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1-
FROM python:3.11-slim
2-
3-
# Set working directory
1+
FROM mcr.microsoft.com/devcontainers/python:3.11-bullseye AS base
42
WORKDIR /app
53

6-
# Install system dependencies
7-
RUN apt-get update && apt-get install -y \
8-
gcc \
9-
&& rm -rf /var/lib/apt/lists/*
4+
FROM base AS builder
5+
6+
# Copy uv binaries from astral-sh image
7+
COPY --from=ghcr.io/astral-sh/uv:0.6.3 /uv /uvx /bin/
8+
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy
9+
10+
# Copy lock and project files first for caching
11+
COPY uv.lock pyproject.toml /app/
12+
13+
# Install dependencies (frozen, no dev) using uv
14+
RUN --mount=type=cache,target=/root/.cache/uv \
15+
uv sync --frozen --no-install-project --no-dev
1016

11-
# Copy requirements first for better caching
12-
COPY requirements.txt .
17+
# Copy application code and install project dependencies
18+
COPY . /app
19+
RUN --mount=type=cache,target=/root/.cache/uv uv sync --frozen --no-dev
20+
21+
# Final stage
22+
FROM base
23+
24+
WORKDIR /app
25+
COPY --from=builder /app /app
26+
COPY --from=builder /bin/uv /bin/uv
1327

14-
# Install Python dependencies
15-
RUN pip install --no-cache-dir -r requirements.txt
16-
####
17-
# Copy the application
18-
COPY . .
28+
# Set PATH to use venv created by uv
29+
ENV PATH="/app/.venv/bin:$PATH"
1930

2031
# Create non-root user
2132
RUN useradd --create-home --shell /bin/bash app && chown -R app:app /app
@@ -28,5 +39,5 @@ EXPOSE 9000
2839
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
2940
CMD curl -f http://localhost:9000/health || exit 1
3041

31-
# Default command
32-
CMD ["python", "mcp_server.py"]
42+
# Run your main script
43+
CMD ["uv", "run", "python", "mcp_server.py", "--transport", "http", "--host", "0.0.0.0", "--port", "9000"]

src/mcp_server/services/data_tool_service.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import logging
33
from typing import List
4-
from ..core.factory import MCPToolBase, Domain
4+
from core.factory import MCPToolBase, Domain
55

66
ALLOWED_FILES = [
77
"competitor_Pricing_Analysis.csv",
@@ -88,3 +88,8 @@ def show_tables() -> List[str]:
8888
"No allowed CSV tables found in '%s' directory.", self.dataset_path
8989
)
9090
return found_tables
91+
92+
@property
93+
def tool_count(self) -> int:
94+
"""Return the number of tools provided by this service."""
95+
return 2 # data_provider and show_tables

0 commit comments

Comments
 (0)