|
3 | 3 | ## Overview |
4 | 4 |
|
5 | 5 | Oracle Database MCP Toolkit is a Model Context Protocol (MCP) server that lets you: |
| 6 | + * Define your own custom tools via a simple YAML configuration file. |
6 | 7 | * Use 8 built-in tools to analyze Oracle JDBC thin client logs and RDBMS/SQLNet trace files. |
7 | 8 | * Optionally use **database-powered tools**, including **vector similarity search** and **SQL execution plan analysis**, when JDBC configuration is provided. |
8 | | - * Define your own custom tools via a simple YAML configuration file. |
| 9 | + |
| 10 | +## Custom Tool Framework — Extending the MCP Server |
| 11 | +The MCP server can load both database connection definitions and custom tool definitions from a YAML configuration file. |
| 12 | +This provides a flexible and declarative way to extend the server without modifying or rebuilding the codebase. |
| 13 | + |
| 14 | +A YAML file may define: |
| 15 | + |
| 16 | +* One or more **sources:** — named database configurations (URL, user, password, etc.) |
| 17 | + |
| 18 | +* One or more **tools** — each with parameters, SQL statements, and optional metadata |
| 19 | + |
| 20 | +### Source Resolution Logic |
| 21 | + |
| 22 | +When executing a tool, the MCP server determines which source to use based on the following rules: |
| 23 | + |
| 24 | +1. If the tool specifies a source, that source is used. |
| 25 | + |
| 26 | +2. If the tool does not specify a source, the server looks for a default source: |
| 27 | + |
| 28 | + * First, it checks whether a source was provided via system properties (db.url, db.user, db.password) (Higher priority). |
| 29 | + |
| 30 | + * If no system property source is available, it falls back to the first source defined in the YAML file, if present. |
| 31 | + |
| 32 | +3. If no source can be resolved and the tool requires one (e.g., SQL-based tools), the server reports a configuration error. |
| 33 | + |
| 34 | +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. |
| 35 | + |
| 36 | +**Example `config.yaml`:** |
| 37 | +```yaml |
| 38 | +sources: |
| 39 | + prod-db: |
| 40 | + url: jdbc:oracle:thin:@prod-host:1521/ORCLPDB1 |
| 41 | + user: ADMIN |
| 42 | + password: ${password} |
| 43 | + |
| 44 | +tools: |
| 45 | + hotels-by-name: |
| 46 | + source: prod-db |
| 47 | + parameters: |
| 48 | + - name: name |
| 49 | + type: string |
| 50 | + description: Hotel name to search for. |
| 51 | + required: false |
| 52 | + statement: SELECT * FROM hotels WHERE name LIKE '%' || :name || '%' |
| 53 | +``` |
| 54 | +To enable YAML configuration, launch the server with: |
| 55 | +```bash |
| 56 | +java -DconfigFile=/path/to/config.yaml -jar <mcp-server>.jar |
| 57 | +``` |
9 | 58 |
|
10 | 59 | ## Built-in Tools |
11 | 60 |
|
@@ -72,55 +121,6 @@ These tools operate on RDBMS/SQLNet trace files: |
72 | 121 |
|
73 | 122 | --- |
74 | 123 |
|
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 | | - |
124 | 124 | ## Prerequisites |
125 | 125 |
|
126 | 126 | - **Java 17+** (JDK) |
|
0 commit comments