Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 74a6e01

Browse files
committed
correctly retrieve the script name
1 parent 1ccba01 commit 74a6e01

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/create_mcp_server/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@
55
from pathlib import Path
66

77
import click
8+
import toml
89
from packaging.version import parse
910

1011
MIN_UV_VERSION = "0.4.10"
1112

1213

14+
class PyProject:
15+
def __init__(self, path: Path):
16+
self.data = toml.load(path)
17+
18+
@property
19+
def name(self) -> str:
20+
return self.data["project"]["name"]
21+
22+
@property
23+
def first_binary(self) -> str | None:
24+
scripts = self.data["project"].get("scripts", {})
25+
return next(iter(scripts.keys()), None)
26+
1327
def check_uv_version(required_version: str) -> str | None:
1428
"""Check if uv is installed and has minimum version"""
1529
try:
@@ -123,7 +137,11 @@ def copy_template(
123137
("README.md.jinja2", "README.md", path),
124138
]
125139

140+
pyproject = PyProject(path / "pyproject.toml")
141+
bin_name = pyproject.first_binary
142+
126143
template_vars = {
144+
"binary_name": bin_name,
127145
"server_name": name,
128146
"server_version": version,
129147
"server_description": description,
@@ -237,6 +255,8 @@ def check_package_name(name: str) -> bool:
237255
return True
238256

239257

258+
259+
240260
@click.command()
241261
@click.option(
242262
"--path",

src/create_mcp_server/template/README.md.jinja2

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,20 @@ On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
5050
Since MCP servers run over stdio, debugging can be challenging. For the best debugging
5151
experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).
5252

53+
{% if binary_name %}
5354
You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command:
5455

5556
```bash
56-
npx @modelcontextprotocol/inspector uv --directory {{server_directory}} run {{server_name}}
57+
npx @modelcontextprotocol/inspector uv --directory {{server_directory}} run {{binary_name}}
5758
```
59+
{% else %}
60+
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:
61+
62+
```bash
63+
npx @modelcontextprotocol/inspector <command-to-run-your-server>
64+
```
65+
66+
Replace `<command-to-run-your-server>` with the specific command you use to start your MCP server.
67+
{% endif %}
5868

5969
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)