Add templated README to projects
This commit is contained in:
parent
318a842fc9
commit
ae6e31527a
2 changed files with 70 additions and 9 deletions
|
|
@ -105,7 +105,9 @@ def get_package_directory(path: Path) -> Path:
|
||||||
return src_dir.parent
|
return src_dir.parent
|
||||||
|
|
||||||
|
|
||||||
def copy_template(path: Path, name: str, version: str = "0.1.0") -> None:
|
def copy_template(
|
||||||
|
path: Path, name: str, description: str, version: str = "0.1.0"
|
||||||
|
) -> None:
|
||||||
"""Copy template files into src/<project_name>"""
|
"""Copy template files into src/<project_name>"""
|
||||||
template_dir = Path(__file__).parent / "template"
|
template_dir = Path(__file__).parent / "template"
|
||||||
|
|
||||||
|
|
@ -116,18 +118,24 @@ def copy_template(path: Path, name: str, version: str = "0.1.0") -> None:
|
||||||
env = Environment(loader=FileSystemLoader(str(template_dir)))
|
env = Environment(loader=FileSystemLoader(str(template_dir)))
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
("__init__.py.jinja2", "__init__.py"),
|
("__init__.py.jinja2", "__init__.py", target_dir),
|
||||||
("server.py.jinja2", "server.py"),
|
("server.py.jinja2", "server.py", target_dir),
|
||||||
|
("README.md.jinja2", "README.md", path),
|
||||||
]
|
]
|
||||||
|
|
||||||
template_vars = {"server_name": name, "server_version": version}
|
template_vars = {
|
||||||
|
"server_name": name,
|
||||||
|
"server_version": version,
|
||||||
|
"server_description": description,
|
||||||
|
"server_directory": str(path.resolve()),
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for template_file, output_file in files:
|
for template_file, output_file, output_dir in files:
|
||||||
template = env.get_template(template_file)
|
template = env.get_template(template_file)
|
||||||
rendered = template.render(**template_vars)
|
rendered = template.render(**template_vars)
|
||||||
|
|
||||||
out_path = target_dir / output_file
|
out_path = output_dir / output_file
|
||||||
out_path.write_text(rendered)
|
out_path.write_text(rendered)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -136,7 +144,7 @@ def copy_template(path: Path, name: str, version: str = "0.1.0") -> None:
|
||||||
|
|
||||||
|
|
||||||
def create_project(
|
def create_project(
|
||||||
path: Path, name: str, version: str, use_claude: bool = True
|
path: Path, name: str, description: str, version: str, use_claude: bool = True
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Create a new project using uv"""
|
"""Create a new project using uv"""
|
||||||
path.mkdir(parents=True, exist_ok=True)
|
path.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
@ -158,7 +166,7 @@ def create_project(
|
||||||
click.echo("❌ Error: Failed to add mcp dependency.", err=True)
|
click.echo("❌ Error: Failed to add mcp dependency.", err=True)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
copy_template(path, name, version)
|
copy_template(path, name, description, version)
|
||||||
|
|
||||||
# Check if Claude.app is available
|
# Check if Claude.app is available
|
||||||
if (
|
if (
|
||||||
|
|
@ -313,7 +321,7 @@ def main(
|
||||||
click.echo("❌ Error: Invalid path. Project creation aborted.", err=True)
|
click.echo("❌ Error: Invalid path. Project creation aborted.", err=True)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
create_project(project_path, name, version, claudeapp)
|
create_project(project_path, name, description, version, claudeapp)
|
||||||
update_pyproject_settings(project_path, version, description)
|
update_pyproject_settings(project_path, version, description)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
53
src/create_mcp_server/template/README.md.jinja2
Normal file
53
src/create_mcp_server/template/README.md.jinja2
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
# {{server_name}} MCP server
|
||||||
|
|
||||||
|
{{server_description}}
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
### Resources
|
||||||
|
|
||||||
|
The server implements a simple note storage system with:
|
||||||
|
- Custom note:// URI scheme for accessing individual notes
|
||||||
|
- Each note resource has a name, description and text/plain mimetype
|
||||||
|
|
||||||
|
### Prompts
|
||||||
|
|
||||||
|
The server provides a single prompt:
|
||||||
|
- summarize-notes: Creates summaries of all stored notes
|
||||||
|
- Optional "style" argument to control detail level (brief/detailed)
|
||||||
|
- Generates prompt combining all current notes with style preference
|
||||||
|
|
||||||
|
### Tools
|
||||||
|
|
||||||
|
The server implements one tool:
|
||||||
|
- add-note: Adds a new note to the server
|
||||||
|
- Takes "name" and "content" as required string arguments
|
||||||
|
- Updates server state and notifies clients of resource changes
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
### Claude Desktop
|
||||||
|
|
||||||
|
Run
|
||||||
|
```
|
||||||
|
mcp setup --app Claude
|
||||||
|
```
|
||||||
|
|
||||||
|
or by editing
|
||||||
|
|
||||||
|
On MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`
|
||||||
|
On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
||||||
|
|
||||||
|
```
|
||||||
|
"mcpServers": {
|
||||||
|
"{{server_name}}": {
|
||||||
|
"command": "uv",
|
||||||
|
"args": [
|
||||||
|
"--directory",
|
||||||
|
"{{server_directory}}",
|
||||||
|
"run",
|
||||||
|
"{{server_name}}"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
Loading…
Reference in a new issue