Skip to content

Commit c49b5fa

Browse files
S0okJujja6312
authored andcommitted
feat: Change isort section for import sorting (#26)
* feat(config): Change isort section for import sorting(#25) - Add lines-between-types in isort section * chore(config): Run the linter(#25) * chore(config): Run the linter(#25) * chore(config): Add linter COM812(#25) * chore(config): Add linter COM812(#25) * chore(config): Arrange toml format(#25) * refactor: rename nova module to compute (#24) * refactor: rename glance module to image (#24) * refactor: rename keystone module to identity (#24) * feat: Register neutron(#26) * fix: Fix conflict --------- Co-authored-by: JIAN <jja6312@naver.com>
1 parent f9643fd commit c49b5fa

File tree

15 files changed

+207
-189
lines changed

15 files changed

+207
-189
lines changed

CONTRIBUTING.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ Format::
3939

4040
**Example**::
4141

42-
feat(nova): implement server management tools
42+
feat(compute): implement server management tools
4343

44-
Add Nova server listing and detail retrieval functionality
44+
Add Compute server listing and detail retrieval functionality
4545
for MCP clients with proper error handling and OpenStack SDK integration.
4646

47-
- Add get_nova_servers tool
47+
- Add get_compute_servers tool
4848
- Add get_server_details tool
4949
- Implement server status filtering
5050
- Add comprehensive error handling

pyproject.toml

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,41 @@ dependencies = [
1414
dev = [
1515
"ruff>=0.12.5",
1616
"pre-commit>=4.2.0",
17-
]
17+
]
1818
test = [
1919
"pytest>=8.4.1",
2020
]
2121

2222

2323
[build-system]
24-
requires = ["hatchling"]
24+
requires = [
25+
"hatchling",
26+
]
2527
build-backend = "hatchling.build"
2628

2729
[tool.hatch.build.targets.wheel]
28-
packages = ["src/openstack_mcp_server"]
30+
packages = [
31+
"src/openstack_mcp_server",
32+
]
2933

3034
[tool.pytest.ini_options]
31-
testpaths = ["tests"]
32-
pythonpath = ["src"]
35+
testpaths = [
36+
"tests",
37+
]
38+
pythonpath = [
39+
"src",
40+
]
3341

34-
python_files = ["test_*.py", "*_test.py"]
35-
python_classes = ["Test*"]
36-
python_functions = ["test_*"]
42+
python_files = [
43+
"test_*.py",
44+
"*_test.py",
45+
]
46+
python_classes = [
47+
"Test*",
48+
]
49+
python_functions = [
50+
"test_*",
51+
]
3752

3853

3954
[tool.ruff]
@@ -49,12 +64,23 @@ line-ending = "auto"
4964
docstring-code-format = true
5065

5166
[tool.ruff.lint]
52-
select = ["C", "E", "F", "S", "U", "I"]
53-
ignore = ["C901", "E501"]
67+
select = [
68+
"C",
69+
"E",
70+
"F",
71+
"S",
72+
"U",
73+
"I",
74+
"COM812",
75+
]
76+
ignore = [
77+
"C901",
78+
"E501",
79+
]
5480

5581
[tool.ruff.lint.isort]
5682
lines-after-imports = 2
57-
no-sections = true
83+
lines-between-types = 1
5884

5985
[tool.ruff.lint.per-file-ignores]
6086
"tests/*" = [

src/openstack_mcp_server/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ def main():
3737
# Validate transport protocol
3838
if MCP_TRANSPORT not in ["stdio", "sse", "streamable-http"]:
3939
logger.error(
40-
f"Invalid transport protocol: {MCP_TRANSPORT}. Using stdio instead."
40+
f"Invalid transport protocol: {MCP_TRANSPORT}. Using stdio instead.",
4141
)
4242
transport = "stdio"
4343
else:
4444
transport = MCP_TRANSPORT
4545

4646
# Start the server
4747
logger.info(
48-
f"Starting Openstack MCP Server with {transport} transport"
48+
f"Starting Openstack MCP Server with {transport} transport",
4949
)
5050

5151
args = parser.parse_args()

src/openstack_mcp_server/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
23
from pathlib import Path
34

45

src/openstack_mcp_server/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from fastmcp.server import FastMCP
22
from fastmcp.server.middleware.error_handling import ErrorHandlingMiddleware
33
from fastmcp.server.middleware.logging import LoggingMiddleware
4+
45
from openstack_mcp_server.tools import register_tool
56

67

src/openstack_mcp_server/tools/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ def register_tool(mcp: FastMCP):
55
"""
66
Register Openstack MCP tools.
77
"""
8-
from .glance_tools import GlanceTools
9-
from .keystone_tools import KeystoneTools
8+
9+
from .compute_tools import ComputeTools
10+
from .identity_tools import IdentityTools
11+
from .image_tools import ImageTools
1012
from .neutron_tools import NeutronTools
11-
from .nova_tools import NovaTools
1213

13-
NovaTools().register_tools(mcp)
14-
GlanceTools().register_tools(mcp)
15-
KeystoneTools().register_tools(mcp)
14+
ComputeTools().register_tools(mcp)
15+
ImageTools().register_tools(mcp)
16+
IdentityTools().register_tools(mcp)
1617
NeutronTools().register_tools(mcp)

src/openstack_mcp_server/tools/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import openstack
2+
23
from openstack import connection
4+
35
from openstack_mcp_server import config
46

57

@@ -17,7 +19,6 @@ def get_connection(cls) -> connection.Connection:
1719
cls._connection = openstack.connect(cloud=config.MCP_CLOUD_NAME)
1820
return cls._connection
1921

20-
2122
# TODO: Close connection
2223

2324

src/openstack_mcp_server/tools/nova_tools.py renamed to src/openstack_mcp_server/tools/compute_tools.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
from .base import get_openstack_conn
21
from fastmcp import FastMCP
3-
from openstack_mcp_server.tools.response.nova import Server
2+
3+
from openstack_mcp_server.tools.response.compute import Server
4+
5+
from .base import get_openstack_conn
46

57

6-
class NovaTools:
8+
class ComputeTools:
79
"""
8-
A class to encapsulate Nova-related tools and utilities.
10+
A class to encapsulate Compute-related tools and utilities.
911
"""
1012

1113
def register_tools(self, mcp: FastMCP):
1214
"""
13-
Register Nova-related tools with the FastMCP instance.
15+
Register Compute-related tools with the FastMCP instance.
1416
"""
1517

16-
mcp.tool()(self.get_nova_servers)
17-
mcp.tool()(self.get_nova_server)
18+
mcp.tool()(self.get_compute_servers)
19+
mcp.tool()(self.get_compute_server)
1820

19-
def get_nova_servers(self) -> list[Server]:
21+
def get_compute_servers(self) -> list[Server]:
2022
"""
21-
Get the list of Nova servers by invoking the registered tool.
23+
Get the list of Compute servers by invoking the registered tool.
2224
23-
:return: A list of Server objects representing the Nova servers.
25+
:return: A list of Server objects representing the Compute servers.
2426
"""
2527
# Initialize connection
2628
conn = get_openstack_conn()
@@ -29,17 +31,17 @@ def get_nova_servers(self) -> list[Server]:
2931
server_list = []
3032
for server in conn.compute.servers():
3133
server_list.append(
32-
Server(name=server.name, id=server.id, status=server.status)
34+
Server(name=server.name, id=server.id, status=server.status),
3335
)
3436

3537
return server_list
3638

37-
def get_nova_server(self, id: str) -> Server:
39+
def get_compute_server(self, id: str) -> Server:
3840
"""
39-
Get a specific Nova server by invoking the registered tool.
41+
Get a specific Compute server by invoking the registered tool.
4042
4143
:param id: The ID of the server to retrieve.
42-
:return: A Server object representing the Nova server.
44+
:return: A Server object representing the Compute server.
4345
"""
4446
# Initialize connection
4547
conn = get_openstack_conn()

src/openstack_mcp_server/tools/keystone_tools.py renamed to src/openstack_mcp_server/tools/identity_tools.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from fastmcp import FastMCP
44

55

6-
class KeystoneTools:
6+
class IdentityTools:
77
"""
8-
A class to encapsulate Keystone-related tools and utilities.
8+
A class to encapsulate Identity-related tools and utilities.
99
"""
1010

1111
def register_tools(self, mcp: FastMCP):
1212
"""
13-
Register Keystone-related tools with the FastMCP instance.
13+
Register Identity-related tools with the FastMCP instance.
1414
"""
1515

1616
mcp.tool()(self.get_regions)
@@ -21,7 +21,7 @@ def register_tools(self, mcp: FastMCP):
2121

2222
def get_regions(self) -> list[Region]:
2323
"""
24-
Get the list of Keystone regions.
24+
Get the list of Identity regions.
2525
2626
:return: A list of Region objects representing the regions.
2727
"""
@@ -30,11 +30,12 @@ def get_regions(self) -> list[Region]:
3030
region_list = []
3131
for region in conn.identity.regions():
3232
region_list.append(
33-
Region(id=region.id, description=region.description)
33+
Region(id=region.id, description=region.description),
3434
)
3535

3636
return region_list
3737

38+
3839
def get_region(self, id: str) -> Region:
3940
"""
4041
Get a region.
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
from .base import get_openstack_conn
21
from fastmcp import FastMCP
32

3+
from .base import get_openstack_conn
4+
45

5-
class GlanceTools:
6+
class ImageTools:
67
"""
7-
A class to encapsulate Nova-related tools and utilities.
8+
A class to encapsulate Compute-related tools and utilities.
89
"""
910

1011
def register_tools(self, mcp: FastMCP):
1112
"""
12-
Register Glance-related tools with the FastMCP instance.
13+
Register Image-related tools with the FastMCP instance.
1314
"""
1415

15-
mcp.tool()(self.get_glance_images)
16+
mcp.tool()(self.get_image_images)
1617

17-
def get_glance_images(self) -> str:
18+
def get_image_images(self) -> str:
1819
"""
19-
Get the list of Glance images by invoking the registered tool.
20+
Get the list of Image images by invoking the registered tool.
2021
2122
:return: A string containing the names, IDs, and statuses of the images.
2223
"""
@@ -27,7 +28,7 @@ def get_glance_images(self) -> str:
2728
image_list = []
2829
for image in conn.image.images():
2930
image_list.append(
30-
f"{image.name} ({image.id}) - Status: {image.status}"
31+
f"{image.name} ({image.id}) - Status: {image.status}",
3132
)
3233

3334
return "\n".join(image_list)

0 commit comments

Comments
 (0)