Skip to content

Commit 26b4d70

Browse files
Merge pull request #12 from Youssef-Erradi/refactoring
Refactoring
2 parents dcd6b3b + 2233526 commit 26b4d70

29 files changed

+692
-241
lines changed
File renamed without changes.

src/oracle-db-toolbox-mcp-server/README.md renamed to src/oracle-db-mcp-toolkit/README.md

Lines changed: 96 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Oracle DB Toolbox MCP Server
1+
# Oracle Database MCP Toolkit
22

33
## Overview
44

5-
`oracle-db-toolbox-mcp-server` is a Model Context Protocol (MCP) server that lets you:
5+
Oracle Database MCP Toolkit is a Model Context Protocol (MCP) server that lets you:
66
* Use 8 built-in tools to analyze Oracle JDBC thin client logs and RDBMS/SQLNet trace files.
77
* Optionally use **database-powered tools**, including **vector similarity search** and **SQL execution plan analysis**, when JDBC configuration is provided.
88
* Define your own custom tools via a simple YAML configuration file.
@@ -71,6 +71,56 @@ These tools operate on RDBMS/SQLNet trace files:
7171
* `llmPrompt`: A structured prompt for an LLM to explain + tune the plan.
7272

7373
---
74+
75+
## Custom Tool Framework — Extending the MCP Server
76+
The MCP server can load both database connection definitions and custom tool definitions from a YAML configuration file.
77+
This provides a flexible and declarative way to extend the server without modifying or rebuilding the codebase.
78+
79+
A YAML file may define:
80+
81+
* One or more **sources:** — named database configurations (URL, user, password, etc.)
82+
83+
* One or more **tools** — each with parameters, SQL statements, and optional metadata
84+
85+
### Source Resolution Logic
86+
87+
When executing a tool, the MCP server determines which source to use based on the following rules:
88+
89+
1. If the tool specifies a source, that source is used.
90+
91+
2. If the tool does not specify a source, the server looks for a default source:
92+
93+
* First, it checks whether a source was provided via system properties (db.url, db.user, db.password) (Higher priority).
94+
95+
* If no system property source is available, it falls back to the first source defined in the YAML file, if present.
96+
97+
3. If no source can be resolved and the tool requires one (e.g., SQL-based tools), the server reports a configuration error.
98+
99+
This design ensures that tools always have a predictable source while giving you flexibility to choose how connections are provided—either inline in YAML or externally via system properties and environment variables.
100+
101+
**Example `config.yaml`:**
102+
```yaml
103+
sources:
104+
prod-db:
105+
url: jdbc:oracle:thin:@prod-host:1521/ORCLPDB1
106+
user: ADMIN
107+
password: ${password}
108+
109+
tools:
110+
hotels-by-name:
111+
source: prod-db
112+
parameters:
113+
- name: name
114+
type: string
115+
description: Hotel name to search for.
116+
required: false
117+
statement: SELECT * FROM hotels WHERE name LIKE '%' || :name || '%'
118+
```
119+
To enable YAML configuration, launch the server with:
120+
```bash
121+
java -DconfigFile=/path/to/config.yaml -jar <mcp-server>.jar
122+
```
123+
74124
## Prerequisites
75125

76126
- **Java 17+** (JDK)
@@ -85,11 +135,11 @@ These tools operate on RDBMS/SQLNet trace files:
85135
mvn clean install
86136
```
87137

88-
The created jar can be found in `target/oracle-db-toolbox-mcp-server-1.0.0.jar`.
138+
The created jar can be found in `target/oracle-db-mcp-toolkit-1.0.0.jar`.
89139

90140
### Transport modes (stdio vs HTTP)
91141

92-
`oracle-db-toolbox-mcp-server` supports two transport modes:
142+
`oracle-db-mcp-toolkit` supports two transport modes:
93143

94144
- **Stdio (default)** – the MCP client spawns the JVM process and talks over stdin/stdout
95145
- **HTTP (streamable)** – the MCP server runs as an HTTP service, and clients connect via a URL
@@ -101,7 +151,7 @@ This is the mode used by tools like Claude Desktop, where the client directly la
101151
```jsonc
102152
{
103153
"mcpServers": {
104-
"oracle-db-toolbox-mcp-server": {
154+
"oracle-db-mcp-toolkit": {
105155
"command": "java",
106156
"args": [
107157
"-Ddb.url=jdbc:oracle:thin:@your-host:1521/your-service",
@@ -110,7 +160,7 @@ This is the mode used by tools like Claude Desktop, where the client directly la
110160
"-Dtools=get-jdbc-stats,get-jdbc-queries",
111161
"-Dojdbc.ext.dir=/path/to/extra-jars",
112162
"-jar",
113-
"<path-to-jar>/oracle-db-toolbox-mcp-server-1.0.0.jar"
163+
"<path-to-jar>/oracle-db-mcp-toolkit-1.0.0.jar"
114164
]
115165
}
116166
}
@@ -132,25 +182,25 @@ java \
132182
-Ddb.user=your_user \
133183
-Ddb.password=your_password \
134184
-Dtools=get-jdbc-stats,get-jdbc-queries \
135-
-jar <path-to-jar>/oracle-db-toolbox-mcp-server-1.0.0.jar
185+
-jar <path-to-jar>/oracle-db-mcp-toolkit-1.0.0.jar
136186
```
137187
This exposes the MCP endpoint at: `http://localhost:45450/mcp`.
138188

139-
### Note
140-
You can enable HTTPS (SSL/TLS) by specifying the path to your certificate keystore and its password using the -DcertificatePath and -DcertificatePassword options.
141-
Only PKCS12 (.p12 or .pfx) keystore format is supported.
142-
You can also change the HTTPS port with the -DhttpsPort option (default is 45451).
189+
#### Enabling HTTPS (SSL/TLS)
190+
To enable HTTPS (SSL/TLS), specify your certificate keystore path and password using the `-DcertificatePath` and `-DcertificatePassword` options.
191+
Only PKCS12 (`.p12` or `.pfx`) keystore files are supported.
192+
You can set the HTTPS port with the `-Dhttps.port` option.
143193
##### Example
144194
```shell
145-
-DcertificatePath=/path/to/your-certificate.p12 -DcertificatePassword=yourPassword -DhttpsPort=443
195+
-DcertificatePath=/path/to/your-certificate.p12 -DcertificatePassword=yourPassword -Dhttps.port=443
146196
```
147197
### Using HTTP from Cline
148198
Cline supports streamable HTTP directly. Example:
149199

150200
```json
151201
{
152202
"mcpServers": {
153-
"oracle-db-toolbox-mcp-server": {
203+
"oracle-db-mcp-toolkit": {
154204
"type": "streamableHttp",
155205
"url": "http://localhost:45450/mcp"
156206
}
@@ -166,7 +216,7 @@ you can use the `mcp-remote` workaround:
166216
```json
167217
{
168218
"mcpServers": {
169-
"oracle-db-toolbox-mcp-server": {
219+
"oracle-db-mcp-toolkit": {
170220
"command": "npx",
171221
"args": [
172222
"-y",
@@ -217,7 +267,7 @@ java \
217267
-DclientId=oracle-db-toolbox \
218268
-DclientSecret=Xj9mPqR2vL5kN8tY3hB7wF4uD6cA1eZ0 \
219269
-DallowedHosts=http://localhost:6274 \
220-
-jar <path-to-jar>/oracle-db-toolbox-mcp-server-1.0.0.jar
270+
-jar <path-to-jar>/oracle-db-mcp-toolkit-1.0.0.jar
221271
```
222272

223273
In the above example, we configured OAuth2 with a local KeyCloak server with a realm named `mcp`, and we only allowed a local [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector)
@@ -234,7 +284,7 @@ java \
234284
-Dtransport=http \
235285
-Dhttp.port=45450 \
236286
-DenableAuthentication=true \
237-
-jar <path-to-jar>/oracle-db-toolbox-mcp-server-1.0.0.jar
287+
-jar <path-to-jar>/oracle-db-mcp-toolkit-1.0.0.jar
238288
```
239289
After starting the server, a UUID token will be generated and logged at <code>INFO</code> level:
240290

@@ -246,7 +296,7 @@ WARNING: OAuth2 is not configured
246296
Nov 25, 2025 3:30:46 PM com.oracle.database.jdbc.oauth.TokenGenerator <init>
247297
INFO: Authorization token generated (for testing and development use only): 0dd11948-37a3-470f-911e-4cd8b3d6f69c
248298
Nov 25, 2025 3:30:46 PM com.oracle.database.jdbc.OracleDBToolboxMCPServer startHttpServer
249-
INFO: [oracle-db-toolbox-mcp-server] HTTP transport started on http://localhost:45450 (endpoint: http://localhost:45450/mcp)
299+
INFO: [oracle-db-mcp-toolkit] HTTP transport started on http://localhost:45450 (endpoint: http://localhost:45450/mcp)
250300
```
251301

252302
If `ORACLE_DB_TOOLBOX_AUTH_TOKEN` environment variable is set:
@@ -268,35 +318,6 @@ INFO: Authorization token generated (for testing and development use only): Secr
268318

269319
Ultimately, the token must be included in the http request header (e.g. `Authorization: Bearer 0dd11948-37a3-470f-911e-4cd8b3d6f69c` or `Authorization: Bearer Secret_DeV_T0ken`).
270320

271-
## YAML Configuration Support
272-
273-
The MCP server supports loading database connection and tool definitions from a YAML configuration file.
274-
For sources, if a tool has a specific source it will use it. Otherwise, it will look for the default source which is either the source we got from system properties, otherwise, the first source defined in the file (if any).
275-
This file can contain environment variables as well.
276-
277-
**Example `config.yaml`:**
278-
```yaml
279-
sources:
280-
prod-db:
281-
url: jdbc:oracle:thin:@prod-host:1521/ORCLPDB1
282-
user: ADMIN
283-
password: ${password}
284-
285-
tools:
286-
hotels-by-name:
287-
source: prod-db
288-
parameters:
289-
- name: name
290-
type: string
291-
description: Hotel name to search for.
292-
required: false
293-
statement: SELECT * FROM hotels WHERE name LIKE '%' || :name || '%'
294-
```
295-
To enable YAML configuration, launch the server with:
296-
```bash
297-
java -DconfigFile=/path/to/config.yaml -jar <mcp-server>.jar
298-
```
299-
300321
### Supported System Properties
301322
<table>
302323
<thead>
@@ -362,6 +383,29 @@ java -DconfigFile=/path/to/config.yaml -jar <mcp-server>.jar
362383
</td>
363384
<td><code>45450</code></td>
364385
</tr>
386+
<tr>
387+
<td><code>https.port</code></td>
388+
<td>No</td>
389+
<td>
390+
TCP port used for SSL connection.
391+
</td>
392+
<td><code>45451</code></td>
393+
</tr>
394+
<tr>
395+
<td><code>certificatePath</code></td>
396+
<td>No</td>
397+
<td>
398+
Path to SSL certificate keystore (Support PKCS12)
399+
</td>
400+
<td><code>/path/to/your/certificate</code></td>
401+
</tr>
402+
<tr>
403+
<td><code>certificatePassword</code></td>
404+
<td>No</td>
405+
<td>
406+
Password of SSL certificate keystore
407+
</td>
408+
</tr>
365409
<tr>
366410
<td><code>configFile</code></td>
367411
<td>No</td>
@@ -431,10 +475,10 @@ A `Dockerfile` is included at the root of the project so you can build and run t
431475
From the project root (where the Dockerfile lives):
432476

433477
```bash
434-
podman build -t oracle-db-toolbox-mcp-server:1.0.0 .
478+
podman build -t oracle-db-mcp-toolkit:1.0.0 .
435479
```
436480
### Run the container (HTTP mode example)
437-
This example runs the MCP server over HTTP inside the container and exposes it on port 45450 on your host.
481+
This example runs the MCP server over HTTP and HTTPS inside the container and exposes it on port 45450 and 45451 on your host.
438482

439483
```bash
440484
podman run --rm \
@@ -451,7 +495,7 @@ podman run --rm \
451495
-Ddb.url=jdbc:oracle:thin:@your-host:1521/your-service \
452496
-Ddb.user=your_user \
453497
-Ddb.password=your_password" \
454-
oracle-db-toolbox-mcp-server:1.0.0
498+
oracle-db-mcp-toolkit:1.0.0
455499
```
456500
This exposes the MCP endpoint at: http://[your-ip-address]:45450/mcp or https://[your-ip-address]:45451/mcp
457501

@@ -475,7 +519,7 @@ podman run --rm \
475519
-Ddb.user=your_user \
476520
-Ddb.password=your_password \
477521
-Dojdbc.ext.dir=/ext" \
478-
oracle-db-toolbox-mcp-server:1.0.0
522+
oracle-db-mcp-toolkit:1.0.0
479523
```
480524

481525
### Using Docker/Podman with stdio
@@ -489,7 +533,7 @@ In this configuration, Claude Desktop runs `podman run --rm -i ... and connects
489533
```json
490534
{
491535
"mcpServers": {
492-
"oracle-db-toolbox-mcp-server": {
536+
"oracle-db-mcp-toolkit": {
493537
"command": "podman",
494538
"args": [
495539
"run",
@@ -498,7 +542,7 @@ In this configuration, Claude Desktop runs `podman run --rm -i ... and connects
498542
"-v", "/absolute/path/to/ext:/ext:ro",
499543
"-e",
500544
"JAVA_TOOL_OPTIONS=-Dtools=get-jdbc-stats,get-jdbc-queries -Ddb.url=jdbc:oracle:thin:@your-host:1521/your-service -Ddb.user=your_user -Ddb.password=your_password -Dojdbc.ext.dir=/ext -DconfigFile=/config/config.yaml",
501-
"oracle-db-toolbox-mcp-server:1.0.0"
545+
"oracle-db-mcp-toolkit:1.0.0"
502546
]
503547
}
504548
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.oracle.database.jdbc</groupId>
8-
<artifactId>oracle-db-toolbox-mcp-server</artifactId>
7+
<groupId>com.oracle.database.mcptoolkit</groupId>
8+
<artifactId>oracle-db-mcp-toolkit</artifactId>
99
<version>1.0.0</version>
1010
<packaging>jar</packaging>
1111
<name>Oracle JDBC Log Analyzer MCP Server</name>
12-
<description>The Oracle JDBC Log Analyzer MCP Server provides tools for analyzing
13-
Oracle JDBC thin client logs and RDBMS/SQLNet trace files.</description>
14-
<url>https://github.com/Youssef-Erradi/mcp/tree/main/src/ojdbc-log-analyzer-mcp-server</url>
12+
<description>The Oracle Database MCP Toolkit is a Model Context Protocol (MCP) server that enables users to analyze Oracle JDBC thin client logs and RDBMS/SQLNet trace files using built-in tools.
13+
It also offers database-powered tools, such as vector similarity search and SQL execution plan analysis. Additionally, users can define custom tools through a YAML configuration file.</description>
14+
<url>https://github.com/oracle/mcp/tree/main/src/oracle-db-mcp-toolkit</url>
1515

1616
<licenses>
1717
<license>
@@ -103,7 +103,7 @@
103103
<createDependencyReducedPom>false</createDependencyReducedPom>
104104
<transformers>
105105
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
106-
<mainClass>com.oracle.database.jdbc.OracleDBToolboxMCPServer</mainClass>
106+
<mainClass>com.oracle.database.mcptoolkit.OracleDatabaseMCPToolkit</mainClass>
107107
</transformer>
108108
</transformers>
109109
</configuration>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
** Oracle Database MCP Toolkit version 1.0.0
3+
**
4+
** Copyright (c) 2025 Oracle and/or its affiliates.
5+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6+
*/
7+
8+
package com.oracle.database.mcptoolkit;
9+
10+
import java.util.regex.*;
11+
12+
/**
13+
* The EnvSubstitutor class provides a method for substituting environment variables in a given string.
14+
* It replaces placeholders in the format ${VARIABLE_NAME} with the corresponding environment variable values.
15+
*/
16+
public class EnvSubstitutor {
17+
/**
18+
* Pattern used to match placeholders in the input string.
19+
* The pattern matches strings in the format ${VARIABLE_NAME}.
20+
*/
21+
private static final Pattern PLACEHOLDER = Pattern.compile("\\$\\{([^}]+)}");
22+
23+
/**
24+
* Substitutes environment variables in the given input string.
25+
*
26+
* @param input the input string containing placeholders for environment variables
27+
* @return the input string with environment variables substituted
28+
* @throws IllegalStateException if an environment variable is not set
29+
*/
30+
public static String substituteEnvVars(String input) {
31+
if (input == null) return null;
32+
Matcher m = PLACEHOLDER.matcher(input);
33+
StringBuffer sb = new StringBuffer();
34+
while (m.find()) {
35+
String var = m.group(1);
36+
String value = System.getenv(var);
37+
if (value == null) {
38+
throw new IllegalStateException("Missing environment variable for: " + var);
39+
}
40+
m.appendReplacement(sb, Matcher.quoteReplacement(value));
41+
}
42+
m.appendTail(sb);
43+
return sb.toString();
44+
}
45+
}

src/oracle-db-toolbox-mcp-server/src/main/java/com/oracle/database/jdbc/LoadedConstants.java renamed to src/oracle-db-mcp-toolkit/src/main/java/com/oracle/database/mcptoolkit/LoadedConstants.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1-
package com.oracle.database.jdbc;
1+
/*
2+
** Oracle Database MCP Toolkit version 1.0.0
3+
**
4+
** Copyright (c) 2025 Oracle and/or its affiliates.
5+
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6+
*/
27

8+
package com.oracle.database.mcptoolkit;
9+
10+
/**
11+
* Provides a set of constants loaded from system properties and environment variables.
12+
* These constants are used to configure various aspects of the application, including
13+
* network settings, tool configurations, OAuth settings, and more.
14+
*
15+
* <p>This class is not intended to be instantiated and provides only static constants.
16+
*/
317
public final class LoadedConstants {
418
private LoadedConstants() {} // Prevent instantiation
519

0 commit comments

Comments
 (0)