|
| 1 | +# Oracle Database Documentation MCP Server |
| 2 | + |
| 3 | +A Python-based MCP (Model Context Protocol) server that provides tools for searching the official Oracle Database documentation. |
| 4 | + |
| 5 | +The MCP server leverages an inverted index to serve snippets of the Oracle Database documentation. Because the Oracle Database documentation is large and gets updated from time to time, it is unfeasible to ship a ready to go documentation index with this repository. Doing so will bloat the repository and runs risk of users searching on an outdated documentation. |
| 6 | + |
| 7 | +Instead, users can create their own index and maintain it as often as required. See [Index creation/maintenance](#index-creationmaintenance) for more on that topic. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Search** |
| 12 | + - Serach the documentation by keywords and phrases |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- Python 3.x |
| 17 | +- Downloaded [Oracle Database Documentation zip file](https://docs.oracle.com/en/database/oracle/oracle-database/26/zip/oracle-database_26.zip) to build the initial index |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +```console |
| 22 | +git clone https://github.com/oracle/mcp.git |
| 23 | + |
| 24 | +cd mcp/src/oracle-db-doc-mcp-server |
| 25 | + |
| 26 | +python3 -m venv .venv |
| 27 | + |
| 28 | +source .venv/bin/activate |
| 29 | + |
| 30 | +python3 -m pip install -r requirements.txt |
| 31 | +``` |
| 32 | + |
| 33 | +## Usage |
| 34 | + |
| 35 | +```console |
| 36 | +usage: oracle-db-doc-mcp-server.py [-h] [-log-level LOG_LEVEL] {idx,mcp} ... |
| 37 | + |
| 38 | +Oracle Database Documentation MCP Server. |
| 39 | + |
| 40 | +options: |
| 41 | + -h, --help show this help message and exit |
| 42 | + -log-level LOG_LEVEL Set the log level (DEBUG, INFO, WARNING, ERROR (default), CRITICAL). |
| 43 | + |
| 44 | +subcommands: |
| 45 | + {idx,mcp} |
| 46 | + idx create/maintain the index |
| 47 | + mcp run the MCP server |
| 48 | +``` |
| 49 | + |
| 50 | +The MCP server has two subcommands: |
| 51 | + |
| 52 | +1. `idx`: Creates or maintains the documentation index. |
| 53 | +2. `mcp`: Runs the MCP server. |
| 54 | + |
| 55 | +Building the index will take some time and some MCP clients will time out while waiting for the index to be built. Hence the two subcommands cannot be intermixed. Users will first have to create the documentation index via the `idx` subcommand and once completed, run the server with the `mcp` subcommand. |
| 56 | + |
| 57 | +### Index creation/maintenance |
| 58 | + |
| 59 | +```console |
| 60 | +usage: oracle-db-doc-mcp-server.py idx [-h] -path PATH [-preprocess PREPROCESS] |
| 61 | + |
| 62 | +options: |
| 63 | + -h, --help show this help message and exit |
| 64 | + -path PATH path to the documentation input zip file or extracted directory |
| 65 | + -preprocess PREPROCESS |
| 66 | + preprocessing level of documentation (NONE, BASIC (default), ADVANCED) |
| 67 | +``` |
| 68 | + |
| 69 | +To create or maintain the index, use the `idx` subcommand and point the `-path` parameter to either the Oracle Database Documentation zip file (the file will be automatically unzipped into a temorary location under `$HOME/.oracle/oracle-db-doc-mcp-server`) or an **already extracted** location of the Oracle Database Documentation. |
| 70 | + |
| 71 | +The server will create a new folder under `$HOME/.oracle/oracle-db-doc-mcp-server` and store the index and the server log file within. Subsequent runs of `mcp` will open that index. The index can be updated by running the `idx` mode again. |
| 72 | + |
| 73 | +The index creation will take several minutes to complete depending on your environment and the level of preprocessing specified via the `-preprocess` parameter. |
| 74 | + |
| 75 | +A checksum of the index is kept so that subsequent executions of the program will only reindex content that has changed. |
| 76 | + |
| 77 | +For example, to create an index on a downloaded Oracle Database documentation zip file under `~/Downloads/oracle-database_26.zip`, run: |
| 78 | + |
| 79 | +```console |
| 80 | +python3 oracle-db-doc-mcp-server.py idx -path ~/Downloads/oracle-database_26.zip |
| 81 | +``` |
| 82 | + |
| 83 | +### Running the MCP Server |
| 84 | + |
| 85 | +```console |
| 86 | +usage: oracle-db-doc-mcp-server.py mcp [-h] [-mode {stdio,http}] [-host HOST] [-port PORT] |
| 87 | + |
| 88 | +options: |
| 89 | + -h, --help show this help message and exit |
| 90 | + -mode {stdio,http} the transport mode for the MCP server (stdio (default) or http) |
| 91 | + -host HOST the IP address (default 0.0.0.0) that the MCP server is reachable at |
| 92 | + -port PORT the port (default 8000) that the MCP server is reachable at |
| 93 | +``` |
| 94 | + |
| 95 | +To run the MCP server, use the `mcp` subcommand. |
| 96 | + |
| 97 | +**Note:** The index will have to exist. If it doesn't, the MCP server will exit with an error. |
| 98 | + |
| 99 | +By default, the MCP server runs on `stdio`. Hence, the simplest way to run it, is: |
| 100 | + |
| 101 | +```console |
| 102 | +python3 oracle-db-doc-mcp-server.py mcp |
| 103 | +``` |
| 104 | + |
| 105 | +### VSCode integration |
| 106 | + |
| 107 | +#### Running the MCP server via Docker/Podman |
| 108 | + |
| 109 | +To run the MCP server from inside a Docker container: |
| 110 | + |
| 111 | +1. Add a new file `.vscode/mcp.json` file to your project folder. |
| 112 | +2. Add the following content to your `mcp.json` file. |
| 113 | + |
| 114 | +``` |
| 115 | +{ |
| 116 | + "servers": { |
| 117 | + "oracle-db-doc": { |
| 118 | + "type": "stdio", |
| 119 | + "command": "docker", |
| 120 | + "args": [ "run", "--rm", "-i", "ghcr.io/oracle/mcp/oracle-db-doc" ] |
| 121 | + } |
| 122 | + } |
| 123 | +} |
| 124 | +``` |
| 125 | + |
| 126 | +#### Running the MCP server directly |
| 127 | + |
| 128 | +To run the MCP server directly from your machine: |
| 129 | + |
| 130 | +1. Follow the [Installation](#installation) instructions first. |
| 131 | +2. Create an index as explained in [Index creation/maintenance](#index-creationmaintenance) |
| 132 | +3. Add a new file `mcp.json` file to your project folder. |
| 133 | +4. Add the following content to your `.vscode/mcp.json` file. Replace the `<>` placeholders with the paths to the MCP server installation. |
| 134 | + |
| 135 | +``` |
| 136 | +{ |
| 137 | + "servers": { |
| 138 | + "oracle-db-doc": { |
| 139 | + "type": "stdio", |
| 140 | + "command": "<installation>/.venv/bin/python3", |
| 141 | + "args": [ "oracle-db-doc-mcp-server.py", "mcp" ] |
| 142 | + } |
| 143 | + } |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +## Tools |
| 148 | + |
| 149 | +### search_oracle_database_documentation |
| 150 | + |
| 151 | +Searches the documentation for key words and key phrases. |
| 152 | + |
| 153 | +```python |
| 154 | +search_oracle_database_documentation(search_query: str, max_results: int) -> list[str]: |
| 155 | +``` |
0 commit comments