Merge pull request #2 from modelcontextprotocol/davidsp/README

Add templated README to projects
This commit is contained in:
David Soria Parra 2024-11-19 22:54:01 +00:00 • committed by GitHub
commit 84c807a5b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 70 additions and 9 deletions

View file

@ -105,7 +105,9 @@ def get_package_directory(path: Path) -> Path:
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>"""
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)))
files = [
("__init__.py.jinja2", "__init__.py"),
("server.py.jinja2", "server.py"),
("__init__.py.jinja2", "__init__.py", target_dir),
("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:
for template_file, output_file in files:
for template_file, output_file, output_dir in files:
template = env.get_template(template_file)
rendered = template.render(**template_vars)
out_path = target_dir / output_file
out_path = output_dir / output_file
out_path.write_text(rendered)
except Exception as e:
@ -136,7 +144,7 @@ def copy_template(path: Path, name: str, version: str = "0.1.0") -> None:
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:
"""Create a new project using uv"""
path.mkdir(parents=True, exist_ok=True)
@ -158,7 +166,7 @@ def create_project(
click.echo("❌ Error: Failed to add mcp dependency.", err=True)
sys.exit(1)
copy_template(path, name, version)
copy_template(path, name, description, version)
# Check if Claude.app is available
if (
@ -313,7 +321,7 @@ def main(
click.echo("❌ Error: Invalid path. Project creation aborted.", err=True)
return 1
create_project(project_path, name, version, claudeapp)
create_project(project_path, name, description, version, claudeapp)
update_pyproject_settings(project_path, version, description)
return 0

View 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}}"
]
}
}
```