Skip to content

Commit 5857890

Browse files
fix: Fix instructions (#13)
* fix: include static files in package distribution - Add hatch build configuration to include static/instructions.md in wheel - Update version to 1.2.0 to match latest git tag - Enhance instructions loading to support both packaged and development paths - Fix FileNotFoundError when installing via uvx from git Resolves issue where tim-mcp fails to start when installed via: uvx --from git+https://github.com/terraform-ibm-modules/tim-mcp.git tim-mcp * chore: update release to increment toml version
1 parent 18fe771 commit 5857890

File tree

4 files changed

+44
-16
lines changed

4 files changed

+44
-16
lines changed

.releaserc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
"plugins": [
55
"@semantic-release/commit-analyzer",
66
"@semantic-release/release-notes-generator",
7-
"@semantic-release/github",
8-
["@semantic-release/git", {
9-
"assets": "false"
10-
}],
117
["@semantic-release/exec", {
8+
"prepareCmd": "if [ -f pyproject.toml ]; then python3 -c \"import re; content = open('pyproject.toml').read(); content = re.sub(r'(version\\s*=\\s*)[\\\"\\'][^\\\"\\']+([\\\"\\'\\)])', r'\\\\1\\\"${nextRelease.version}\\\"\\\\2', content); open('pyproject.toml', 'w').write(content); print('Updated pyproject.toml version to ${nextRelease.version}')\"; else echo 'No pyproject.toml found, skipping Python version update'; fi",
129
"successCmd": "echo \"SEMVER_VERSION=${nextRelease.version}\" >> $GITHUB_ENV"
13-
}]
10+
}],
11+
["@semantic-release/git", {
12+
"assets": ["pyproject.toml"],
13+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
14+
}],
15+
"@semantic-release/github"
1416
]
1517
}

pyproject.toml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "tim-mcp"
7-
version = "0.1.0"
7+
version = "1.2.0"
88
description = "Terraform IBM Modules MCP"
99
readme = "README.md"
1010
requires-python = ">=3.11"
@@ -67,3 +67,15 @@ dev = [
6767
"pytest-asyncio>=0.24.0",
6868
"ruff>=0.8.4",
6969
]
70+
71+
[tool.hatch.build]
72+
include = [
73+
"tim_mcp/**/*.py",
74+
"static/**/*",
75+
]
76+
77+
[tool.hatch.build.targets.wheel]
78+
packages = ["tim_mcp"]
79+
80+
[tool.hatch.build.targets.wheel.force-include]
81+
"static" = "tim_mcp/static"

tim_mcp/server.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,29 @@
3232

3333
def _load_instructions() -> str:
3434
"""Load instructions from the static instructions file."""
35-
instructions_path = Path(__file__).parent.parent / "static" / "instructions.md"
36-
try:
37-
return instructions_path.read_text(encoding="utf-8")
38-
except FileNotFoundError as e:
39-
logger.error(f"Instructions file not found at {instructions_path}")
40-
raise FileNotFoundError(
41-
f"Required instructions file not found: {instructions_path}. "
42-
f"Please ensure the instructions.md file exists in the static directory."
43-
) from e
35+
# First try the packaged location (when installed via pip/uvx)
36+
packaged_path = Path(__file__).parent / "static" / "instructions.md"
37+
# Then try the development location (when running from source)
38+
dev_path = Path(__file__).parent.parent / "static" / "instructions.md"
39+
40+
for instructions_path in [packaged_path, dev_path]:
41+
if instructions_path.exists():
42+
try:
43+
return instructions_path.read_text(encoding="utf-8")
44+
except Exception as e:
45+
logger.error(
46+
f"Error reading instructions file at {instructions_path}: {e}"
47+
)
48+
continue
49+
50+
# If neither path works, provide helpful error message
51+
logger.error(f"Instructions file not found at {packaged_path} or {dev_path}")
52+
raise FileNotFoundError(
53+
f"Required instructions file not found. Searched locations:\n"
54+
f" - {packaged_path} (packaged installation)\n"
55+
f" - {dev_path} (development installation)\n"
56+
f"Please ensure the instructions.md file exists in the static directory."
57+
)
4458

4559

4660
# Initialize FastMCP server

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)