Skip to content

Commit 4f9b33b

Browse files
committed
feat(generator): add mcp cookie cutter template
1 parent 36218c9 commit 4f9b33b

File tree

25 files changed

+645
-0
lines changed

25 files changed

+645
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Prototypes and proofs-of-concept
99
| [agent](./agent) | An example agent developed using LangGraph that drives the OCI CLI |
1010
| [policy](./policy) | Demonstration of out-of-band policy enforcement for MCP servers/tools |
1111
| [server](./server) | Example of MCP authentication using OCI IDCS and OAuth |
12+
| [generator](./generator) | A utility to quickly generate an OCI-specific MCP server using [cookiecutter](https://cookiecutter.readthedocs.io/en/stable/) |
1213

1314
## Getting started
1415

generator/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# OCI MCP Server Generator
2+
3+
This directory contains a Cookiecutter template for generating OCI MCP servers.
4+
5+
## Prerequisites
6+
7+
- Python 3.9 or higher
8+
- UV (`brew install uv`)
9+
- Cookiecutter (`pip install cookiecutter`)
10+
11+
## Usage
12+
13+
1. If you want to use the existing cookiecutter template in another project like the [Oracle MCP](https://github.com/oracle/mcp), run the below command. You may need to change the `output-dir`
14+
```
15+
uvx cookiecutter https://github.com/oracle-samples/mcp-examples.git --directory generator --output-dir ./src
16+
```
17+
18+
2. Follow the prompts to enter the required information
19+
3. Cookiecutter will generate a new directory with your MCP server project.
20+
21+
## Testing
22+
23+
1. If you want to test the project template, run the below command
24+
```
25+
uvx cookiecutter generator
26+
```
27+
2. Following the prompts and it will generator a directory with your MCP servers.
28+
3. Adjust the files within the `generator` folder to modify the output
29+
4. For dynamic variables or advanced usage, see the [official readme](https://cookiecutter.readthedocs.io/en/stable/README.html)
30+
5. Do not commit generated code to this repository
31+
32+
## Generated Project Structure
33+
34+
Here's an example of the directory structure generated by this template when using "test" as the project_domain:
35+
36+
```
37+
oci-test-mcp-server/
38+
├── .gitignore
39+
├── .python-version
40+
├── CHANGELOG.md
41+
├── LICENSE.txt
42+
├── pyproject.toml
43+
├── README.md
44+
├── uv-requirements.txt
45+
└── oracle/
46+
├── __init__.py
47+
└── oci_test_mcp_server/
48+
├── __init__.py
49+
├── server.py
50+
└── tests/
51+
```
52+
53+
## Template Variables
54+
55+
- `project_domain`: Used to generate the project directory name and other identifiers.
56+
- `description`: Used to generate a description of the project.
57+
- `instructions`: "Instructions for using this MCP server.
58+
59+
## Notes
60+
61+
- The generated MCP server project includes basic configuration and structure. You will need to modify and extend it according to your specific requirements.
62+
- Refer to the [Cookiecutter documentation](https://cookiecutter.readthedocs.io/) for more advanced usage and customization options.

generator/cookiecutter.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"_copy_without_render": [
3+
".gitignore"
4+
],
5+
"project_domain": "This is the domain of your service. It will be used to generate folders in the structure of 'oracle.oci-{project_domain}-mcp-server'",
6+
"description": "An OCI Model Context Protocol server for {{ cookiecutter.project_domain }}",
7+
"instructions": "Instructions for using this {{ cookiecutter.project_domain }} MCP server. This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a 'hint' to the model. For example, this information MAY be added to the system prompt. Important to be clear, direct, and detailed."
8+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
share/python-wheels/
20+
*.egg-info/
21+
.installed.cfg
22+
*.egg
23+
MANIFEST
24+
25+
# Virtual environments
26+
.venv
27+
env/
28+
venv/
29+
ENV/
30+
31+
# IDE
32+
.idea/
33+
.vscode/
34+
*.swp
35+
*.swo
36+
37+
# Testing
38+
.tox/
39+
.coverage
40+
.coverage.*
41+
htmlcov/
42+
.pytest_cache/
43+
44+
# Ruff
45+
.ruff_cache/
46+
47+
# Build
48+
*.manifest
49+
*.spec
50+
.pybuilder/
51+
target/
52+
53+
# Environments
54+
.env
55+
.env.local
56+
.env.*.local
57+
58+
# PyPI
59+
.pypirc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## Unreleased
9+
10+
### Added
11+
12+
- Initial project setup
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2025 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# OCI {{cookiecutter.project_domain}} MCP Server
2+
3+
{{cookiecutter.description}}
4+
5+
## Instructions
6+
7+
{{cookiecutter.instructions}}
8+
9+
## TODO (REMOVE AFTER COMPLETING)
10+
11+
* [ ] Generate a `uv.lock` file with `uv sync` -> See [Getting Started](https://docs.astral.sh/uv/getting-started/)
12+
* [ ] Remove the example tools in `./oracle/oci-{{cookiecutter.project_domain | lower | replace(' ', '-') | replace('_', '-') | replace('-', '_')}}_mcp_server/server.py`
13+
* [ ] Add your own tool(s)
14+
* [ ] Keep test coverage at or above the `main` branch
15+
* [ ] Document the MCP Server in this "README.md"
16+
* [ ] Submit a PR and pass all the checks
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
Copyright (c) 2025, Oracle and/or its affiliates.
3+
Licensed under the Universal Permissive License v1.0 as shown at
4+
https://oss.oracle.com/licenses/upl.
5+
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
Copyright (c) 2025, Oracle and/or its affiliates.
3+
Licensed under the Universal Permissive License v1.0 as shown at
4+
https://oss.oracle.com/licenses/upl.
5+
"""
6+
7+
"""oracle.oci-{{cookiecutter.project_domain | lower | replace(' ', '-') | replace('_', '-')}}-mcp-server"""
8+
9+
__version__ = '0.0.0'
10+
__project__ = "oracle.oci-{{cookiecutter.project_domain | lower | replace(' ', '-') | replace('_', '-')}}-mcp-server"

0 commit comments

Comments
 (0)