Commit 6c009356 authored by Kostas Chartsias's avatar Kostas Chartsias
Browse files

doc(mcp_module) to reflect the changes of the last commits

parent b5c3f098
Loading
Loading
Loading
Loading
Loading
+36 −21
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@

This project implements an MCP server that exposes **CAMARA-compliant APIs** through the [`FastMCP`](https://pypi.org/project/fastmcp/) framework integrated with [`FastAPI`](https://fastapi.tiangolo.com/), allowing integration with AI agents and enabled agentic workflows.

The MCP server is mounted on FastAPI at `/mcp` endpoint, allowing you to serve both MCP tools and standard REST API endpoints from the same application.
The MCP server is mounted on FastAPI, with a standard REST health endpoint at `/health`.

---

@@ -14,21 +14,17 @@ The MCP server is mounted on FastAPI at `/mcp` endpoint, allowing you to serve b
```
mcp_module/

├── dummy_backend/           # This repository contains a dummy backend implementation of CAMARA API endpoints
├── json_templates/          # CAMARA API request/response templates (interpolated by user input)
├── json_templates/          # Request templates interpolated by MCP tools
├── models/                  # Pydantic models for CAMARA API compliance or custom types
├── tools/                   # MCP tools registered as callable endpoints
│   ├── qod.py               # Quality of Demand (QoD) related tools leveraging OOP OEG
│   └── edge_application.py  # Discovery of edge applications leveraging OOP OEG

├── security/                # Security-related module placeholders
├── app.py
├── requirements.txt
└── Dockerfile
```
---

* **`json_templates/`**: Contains CAMARA-compatible JSON structures that act as request/response templates.
  These are dynamically **interpolated** using user input before being sent to CAMARA endpoint.
* **`json_templates/`**: Contains JSON request templates interpolated with tool input before being sent to the OEG endpoint.

* **`models/`**: Contains **Pydantic models** that mirror CAMARA API specifications from
  [CAMARA API to MCP Mapping](https://lf-camaraproject.atlassian.net/wiki/spaces/CAM/pages/222691579/CAMARA+API+to+MCP+Tool+Mapping).
@@ -38,11 +34,18 @@ mcp_module/
* All MCP tools are explicitly registered in `app.py` for safety and traceability:

| Tool | File | Description |
| -------------------------- | --------------------------- |------------------------------------------|
| --- | --- | --- |
| `create_qod_session_oai` | `tools/qod.py` | Creates a CAMARA QoD session |
| `get_qod_session_oai` | `tools/qod.py` | Retrieves QoD session details |
| `delete_qod_session_oai` | `tools/qod.py` | Deletes an existing QoD session |
| `get_app_definitions`      | `tools/edge_application.py` | Retrieves available edge app definitions |
| `get_app_definitions` | `tools/edge_application.py` | Lists available edge app definitions |
| `register_app_definition` | `tools/edge_application.py` | Registers an app definition from package type, image path, and port |
| `get_app_definition` | `tools/edge_application.py` | Retrieves one app definition by id |
| `delete_app_definition` | `tools/edge_application.py` | Deletes one app definition by id |
| `get_edge_cloud_zones` | `tools/edge_application.py` | Lists edge cloud zones |
| `instantiate_app` | `tools/edge_application.py` | Instantiates an app to one or more edge cloud zones |
| `get_app_instances` | `tools/edge_application.py` | Lists instantiated/deployed applications |
| `delete_app_instance` | `tools/edge_application.py` | Deletes one app instance by id |

---

@@ -56,11 +59,14 @@ cd mcp_module
python3 -m venv venv
source venv/bin/activate  # (on Linux/macOS) venv\Scripts\activate     # (on Windows)
pip install -r requirements.txt
```

Create a `.env` file in the project root (if not already present) and set your API configuration:

```
OEG_SERVICE_URL=http://your-oeg-host/oeg/1.0.0

MCP_HOST=127.0.0.1
MCP_PORT=8004
```


@@ -84,7 +90,7 @@ Run the application with:
python app.py
```

By default, it runs on `0.0.0.0:8004`.
By default, it runs on `127.0.0.1:8004` unless overridden by `MCP_HOST` and `MCP_PORT`.

### Option 2 - Containerized
Run the container:
@@ -97,18 +103,27 @@ docker run -p 8004:8004 -e OEG_SERVICE_URL=http://your-oeg-host/oeg/1.0.0 mcp_mo
## 🧩 Integration with 3rd party apps
Open-WebUI 0.6.34 - Python 3.11.x

## Edge App Notes

`register_app_definition` derives `name` and `componentName` from the final image path segment before `:` and appends a short random suffix, so repeated registrations of the same image can coexist.

Request templates used by edge app tools:

| Template | Used by |
| --- | --- |
| `json_templates/app_register_app_definition_request.json` | `register_app_definition` |
| `json_templates/app_instantiate_request.json` | `instantiate_app` |


## 🧩 Extending the Project

To add a new tool:
1. Define Pydantic models for request, response data schema validation.
2. Define the tool in `tools/your_tool.py`.
3. Registers a tool in `app.py`:
3. Register the tool in `app.py`.
4. Add corresponding models and JSON templates if needed.

---
## Roadmap
Extend the MCP server with relevant prompts, tool call(s), and more comprehensive parameter assertions.