Skip to content

Commit f9efb70

Browse files
committed
* Ported code to RMCP
* Implemented unit and e2e testing * Other fixes and enhancements
1 parent 13f93cc commit f9efb70

28 files changed

Lines changed: 1528 additions & 2787 deletions

Cargo.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mcp-server-wazuh"
3-
version = "0.1.0"
3+
version = "0.1.2"
44
edition = "2021"
55
description = "Wazuh SIEM MCP Server"
66
authors = ["Gianluca Brigandi <gbrigand@gmail.com>"]
@@ -21,6 +21,7 @@ schemars = "0.8"
2121
clap = { version = "4.5", features = ["derive"] }
2222
dotenv = "0.15"
2323
thiserror = "2.0"
24+
chrono = "0.4.41"
2425

2526
[dev-dependencies]
2627
mockito = "1.7"
@@ -30,9 +31,7 @@ uuid = { version = "1.16", features = ["v4"] }
3031
once_cell = "1.21"
3132
async-trait = "0.1"
3233
regex = "1.11"
33-
34-
# Test binaries are disabled for now due to dependency conflicts
35-
# [[bin]]
36-
# name = "mcp_client_cli"
37-
# path = "tests/mcp_client_cli.rs"
34+
tokio-test = "0.4"
35+
serde_json = "1.0"
36+
tempfile = "3.0"
3837

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN apt-get update && \
77
apt-get install -y pkg-config libssl-dev && \
88
cargo build --release
99

10-
FROM debian:bullseye-slim
10+
FROM debian:bookworm-slim
1111

1212
RUN apt-get update && \
1313
apt-get install -y ca-certificates && \

README.md

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,6 @@ This stdio interaction allows for tight integration with local development tools
169169
```
170170
If the HTTP server is enabled, it will start listening on the port specified by `MCP_SERVER_PORT` (default 8000). Otherwise, it will operate in stdio mode.
171171

172-
### Docker Deployment
173-
174-
1. **Clone the repository** (if not already done).
175-
2. **Configure:** Ensure you have a `.env` file with your Wazuh credentials in the project root if using the API, or set the environment variables directly in the `docker-compose.yml` or your deployment environment.
176-
3. **Build and Run:**
177-
```bash
178-
docker-compose up --build -d
179-
```
180-
This will build the Docker image and start the container in detached mode.
181-
182172
## Stdio Mode Operation
183173

184174
The server communicates via `stdin` and `stdout` using JSON-RPC 2.0 messages, adhering to the Model Context Protocol (MCP).
@@ -348,60 +338,6 @@ Example interaction flow:
348338
}
349339
```
350340
351-
## Running the All-in-One Demo (Wazuh + MCP Server)
352-
353-
For a complete local demo environment that includes Wazuh (Indexer, Manager, Dashboard) and the Wazuh MCP Server pre-configured to connect to it (for HTTP mode testing), you can use the `docker-compose.all-in-one.yml` file.
354-
355-
This setup is ideal for testing the end-to-end flow from Wazuh alerts to MCP messages via the HTTP interface.
356-
357-
**1. Launch the Environment:**
358-
359-
Navigate to the project root directory in your terminal and run:
360-
361-
```bash
362-
docker-compose -f docker-compose.all-in-one.yml up -d
363-
```
364-
365-
This command will:
366-
- Download the necessary Wazuh and OpenSearch images (if not already present).
367-
- Start the Wazuh Indexer, Wazuh Manager, and Wazuh Dashboard services.
368-
- Build and start the Wazuh MCP Server (in HTTP mode).
369-
- All services are configured to communicate with each other on an internal Docker network.
370-
371-
**2. Accessing Services:**
372-
373-
* **Wazuh Dashboard:**
374-
* URL: `https://localhost:8443` (Note: Uses HTTPS with a self-signed certificate, so your browser will likely show a warning).
375-
* Default Username: `admin`
376-
* Default Password: `AdminPassword123!` (This is set by `WAZUH_INITIAL_PASSWORD` in the `wazuh-indexer` service).
377-
378-
* **Wazuh MCP Server (HTTP Mode):**
379-
* The MCP server will be running and accessible on port `8000` by default (or the port specified by `MCP_SERVER_PORT` if you've set it as an environment variable on your host machine before running docker-compose).
380-
* Example MCP endpoint: `http://localhost:8000/mcp`
381-
* Example Health endpoint: `http://localhost:8000/health`
382-
* **Configuration:** The `mcp-server` service within `docker-compose.all-in-one.yml` is already configured with the necessary environment variables to connect to the `wazuh-manager` service:
383-
* `WAZUH_HOST=wazuh-manager`
384-
* `WAZUH_PORT=55000`
385-
* `WAZUH_USER=wazuh_user_demo`
386-
* `WAZUH_PASS=wazuh_password_demo`
387-
* `VERIFY_SSL=false`
388-
You do not need to set these in a separate `.env` file when using this all-in-one compose file, as they are defined directly in the service's environment.
389-
390-
**3. Stopping the Environment:**
391-
392-
To stop all services, run:
393-
394-
```bash
395-
docker-compose -f docker-compose.all-in-one.yml down
396-
```
397-
398-
To stop and remove volumes (deleting Wazuh data):
399-
400-
```bash
401-
docker-compose -f docker-compose.all-in-one.yml down -v
402-
```
403-
This approach simplifies setup by bundling all necessary components and their configurations for HTTP mode testing.
404-
405341
## Development & Testing
406342
407343
- **Code Style:** Uses standard Rust formatting (`cargo fmt`).

media/.DS_Store

6 KB
Binary file not shown.

run.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/http_service.rs

Lines changed: 0 additions & 135 deletions
This file was deleted.

src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// This file is kept for compatibility with existing tests and binaries
2-
// The main MCP server functionality has been moved to main.rs using the rmcp framework
3-
41
pub mod wazuh;
52

6-
// Re-export for backward compatibility
73
pub use wazuh::client::WazuhIndexerClient;
84
pub use wazuh::error::WazuhApiError;

0 commit comments

Comments
 (0)