diff --git a/src/create_mcp_server/__init__.py b/src/create_mcp_server/__init__.py index 6e1d342..99f57fd 100644 --- a/src/create_mcp_server/__init__.py +++ b/src/create_mcp_server/__init__.py @@ -5,11 +5,25 @@ import sys from pathlib import Path import click +import toml from packaging.version import parse MIN_UV_VERSION = "0.4.10" +class PyProject: + def __init__(self, path: Path): + self.data = toml.load(path) + + @property + def name(self) -> str: + return self.data["project"]["name"] + + @property + def first_binary(self) -> str | None: + scripts = self.data["project"].get("scripts", {}) + return next(iter(scripts.keys()), None) + def check_uv_version(required_version: str) -> str | None: """Check if uv is installed and has minimum version""" try: @@ -123,7 +137,11 @@ def copy_template( ("README.md.jinja2", "README.md", path), ] + pyproject = PyProject(path / "pyproject.toml") + bin_name = pyproject.first_binary + template_vars = { + "binary_name": bin_name, "server_name": name, "server_version": version, "server_description": description, @@ -237,6 +255,8 @@ def check_package_name(name: str) -> bool: return True + + @click.command() @click.option( "--path", diff --git a/src/create_mcp_server/template/README.md.jinja2 b/src/create_mcp_server/template/README.md.jinja2 index 644456b..7abfe66 100644 --- a/src/create_mcp_server/template/README.md.jinja2 +++ b/src/create_mcp_server/template/README.md.jinja2 @@ -50,10 +50,20 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json` Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector). +{% if binary_name %} You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command: ```bash -npx @modelcontextprotocol/inspector uv --directory {{server_directory}} run {{server_name}} +npx @modelcontextprotocol/inspector uv --directory {{server_directory}} run {{binary_name}} +``` +{% else %} +This project does not contain a script to start. However, you can still use the MCP Inspector for debugging. To start the inspector, use the following general command structure: + +```bash +npx @modelcontextprotocol/inspector ``` +Replace `` with the specific command you use to start your MCP server. +{% endif %} + Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging. diff --git a/uv.lock b/uv.lock index ba63f9a..372f52f 100644 --- a/uv.lock +++ b/uv.lock @@ -24,7 +24,7 @@ wheels = [ [[package]] name = "create-mcp-server" -version = "1.0.1.dev0" +version = "1.0.3.dev0" source = { editable = "." } dependencies = [ { name = "click" },