Resolve "(CTTC) TeraFlowSDN Model Context Protocol (MCP) server"

Closes #413 (closed)

Merge request reports

Loading
+4 −0
Changes for deploy/all.sh: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -72,6 +72,10 @@ export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device pathcomp service slice n
# Uncomment to activate Pluggables Component
#export TFS_COMPONENTS="${TFS_COMPONENTS} pluggables"

# Uncomment to activate MCP Server.
# Keep it last so it is deployed after optional components it can expose.
#export TFS_COMPONENTS="${TFS_COMPONENTS} mcp_server"

# If not already set, set the tag you want to use for your images.
export TFS_IMAGE_TAG=${TFS_IMAGE_TAG:-"dev"}

+105 −0
Changes for manifests/mcp_serverservice.yaml: 105 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mcp-serverservice
spec:
  selector:
    matchLabels:
      app: mcp-serverservice
  replicas: 1
  template:
    metadata:
      labels:
        app: mcp-serverservice
    spec:
      terminationGracePeriodSeconds: 5
      containers:
        - name: server
          image: labs.etsi.org:5050/tfs/controller/mcp_server:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 3002
          env:
            - name: LOG_LEVEL
              value: "INFO"
            - name: TFS_MCP_PORT
              value: "3002"
            - name: TFS_MCP_MODE
              value: "normal"
            - name: TFS_NBI_URL
              value: "http://nbiservice:8080"
            - name: TFS_NBI_PREFIX
              value: "/tfs-api"
          readinessProbe:
            httpGet:
              path: /health
              port: 3002
            initialDelaySeconds: 5
            periodSeconds: 10
            failureThreshold: 10
          livenessProbe:
            httpGet:
              path: /health
              port: 3002
            initialDelaySeconds: 5
            periodSeconds: 10
            failureThreshold: 10
          resources:
            requests:
              cpu: 50m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 512Mi
---
apiVersion: v1
kind: Service
metadata:
  name: mcp-serverservice
  labels:
    app: mcp-serverservice
spec:
  type: ClusterIP
  selector:
    app: mcp-serverservice
  ports:
    - name: http
      protocol: TCP
      port: 3002
      targetPort: 3002
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: tfs-ingress-mcp-server
  annotations:
    nginx.ingress.kubernetes.io/limit-rps: "50"             # max requests per second per source IP
    nginx.ingress.kubernetes.io/limit-connections: "50"     # max concurrent connections per source IP
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "60" # max timeout for connecting to server
    nginx.ingress.kubernetes.io/proxy-send-timeout: "3600"  # max timeout between two successive read operations
    nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"  # max timeout between two successive write operations
spec:
  rules:
    - http:
        paths:
          - path: /mcp
            pathType: Prefix
            backend:
              service:
                name: mcp-serverservice
                port:
                  number: 3002
+27 −0
Changes for scripts/show_logs_mcp_server.sh: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

########################################################################################################################
# Define your deployment settings here
########################################################################################################################

# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}

########################################################################################################################
# Automated steps start here
########################################################################################################################

kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/mcp-serverservice -c server
+3 −0
Changes for src/common/Constants.py: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ class ServiceNameEnum(Enum):
    POLICY                 = 'policy'
    MONITORING             = 'monitoring'
    DLT                    = 'dlt'
    MCP_SERVER             = 'mcp-server'
    NBI                    = 'nbi'
    SIMAP_CONNECTOR        = 'simap-connector'
    CYBERSECURITY          = 'cybersecurity'
@@ -127,6 +128,7 @@ DEFAULT_SERVICE_GRPC_PORTS = {

# Default HTTP/REST-API service ports
DEFAULT_SERVICE_HTTP_PORTS = {
    ServiceNameEnum.MCP_SERVER.value : 3002,
    ServiceNameEnum.NBI  .value      : 8080,
    ServiceNameEnum.WEBUI.value      : 8004,
    ServiceNameEnum.ZTP_SERVER.value : 8005,
@@ -134,6 +136,7 @@ DEFAULT_SERVICE_HTTP_PORTS = {

# Default HTTP/REST-API service base URLs
DEFAULT_SERVICE_HTTP_BASEURLS = {
    ServiceNameEnum.MCP_SERVER.value : None,
    ServiceNameEnum.NBI  .value : None,
    ServiceNameEnum.WEBUI.value : None,
}
+48 −0
Changes for src/mcp_server/service/tools/Base.py: 48 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Any, Callable, Dict, Optional

from mcp_server.service.Dependencies import format_response


class ToolHandler:
    async def handle(self, server, args: Dict[str, Any]) -> str:
        raise NotImplementedError()


class NbiRestToolHandler(ToolHandler):
    def __init__(
        self,
        method: str,
        endpoint: str,
        json_factory: Optional[Callable[[Dict[str, Any]], Any]] = None,
        use_prefix: bool = True,
        timeout: float = 60.0,
    ):
        self.method = method
        self.endpoint = endpoint
        self.json_factory = json_factory
        self.use_prefix = use_prefix
        self.timeout = timeout

    async def handle(self, server, args: Dict[str, Any]) -> str:
        json_data = None if self.json_factory is None else self.json_factory(args)
        return format_response(await server.api_request(
            self.method,
            self.endpoint.format(**args),
            json_data=json_data,
            timeout=self.timeout,
            use_prefix=self.use_prefix,
        ))
Loading
Loading