88from starlette .middleware .trustedhost import TrustedHostMiddleware
99
1010from .aura_manager import AuraManager
11- from .utils import get_logger
11+ from .utils import get_logger , format_namespace
1212
1313logger = get_logger (__name__ )
1414
1515
16- def create_mcp_server (aura_manager : AuraManager ) -> FastMCP :
16+
17+ def create_mcp_server (aura_manager : AuraManager , namespace : str = "" ) -> FastMCP :
1718 """Create an MCP server instance for Aura management."""
1819
20+ namespace_prefix = format_namespace (namespace )
21+
1922 mcp : FastMCP = FastMCP ("mcp-neo4j-aura-manager" , dependencies = ["requests" , "pydantic" , "starlette" ])
2023
21- @mcp .tool (annotations = ToolAnnotations (title = "List Instances" ,
24+ @mcp .tool (
25+ name = namespace_prefix + "list_instances" ,
26+ annotations = ToolAnnotations (title = "List Instances" ,
2227 readOnlyHint = True ,
2328 destructiveHint = False ,
2429 idempotentHint = True ,
@@ -30,19 +35,24 @@ async def list_instances() -> dict:
3035 result = await aura_manager .list_instances ()
3136 return result
3237
33- @mcp .tool (annotations = ToolAnnotations (title = "Get Instance Details" ,
34- readOnlyHint = True ,
35- destructiveHint = False ,
36- idempotentHint = True ,
37- openWorldHint = True
38+ @mcp .tool (
39+ name = namespace_prefix + "get_instance_details" ,
40+ annotations = ToolAnnotations (
41+ title = "Get Instance Details" ,
42+ readOnlyHint = True ,
43+ destructiveHint = False ,
44+ idempotentHint = True ,
45+ openWorldHint = True
3846
3947 ))
4048 async def get_instance_details (instance_ids : List [str ]) -> dict :
4149 """Get details for one or more Neo4j Aura instances by ID."""
4250 result = await aura_manager .get_instance_details (instance_ids )
4351 return result
4452
45- @mcp .tool (annotations = ToolAnnotations (title = "Get Instance by Name" ,
53+ @mcp .tool (
54+ name = namespace_prefix + "get_instance_by_name" ,
55+ annotations = ToolAnnotations (title = "Get Instance by Name" ,
4656 readOnlyHint = True ,
4757 destructiveHint = False ,
4858 idempotentHint = True ,
@@ -54,7 +64,9 @@ async def get_instance_by_name(name: str) -> dict:
5464 result = await aura_manager .get_instance_by_name (name )
5565 return result
5666
57- @mcp .tool (annotations = ToolAnnotations (title = "Create Instance" ,
67+ @mcp .tool (
68+ name = namespace_prefix + "create_instance" ,
69+ annotations = ToolAnnotations (title = "Create Instance" ,
5870 readOnlyHint = False ,
5971 destructiveHint = False ,
6072 idempotentHint = True ,
@@ -86,7 +98,9 @@ async def create_instance(
8698 )
8799 return result
88100
89- @mcp .tool (annotations = ToolAnnotations (title = "Update Instance Name" ,
101+ @mcp .tool (
102+ name = namespace_prefix + "update_instance_name" ,
103+ annotations = ToolAnnotations (title = "Update Instance Name" ,
90104 readOnlyHint = False ,
91105 destructiveHint = True ,
92106 idempotentHint = True ,
@@ -98,7 +112,9 @@ async def update_instance_name(instance_id: str, name: str) -> dict:
98112 result = await aura_manager .update_instance_name (instance_id , name )
99113 return result
100114
101- @mcp .tool (annotations = ToolAnnotations (title = "Update Instance Memory" ,
115+ @mcp .tool (
116+ name = namespace_prefix + "update_instance_memory" ,
117+ annotations = ToolAnnotations (title = "Update Instance Memory" ,
102118 readOnlyHint = False ,
103119 destructiveHint = True ,
104120 idempotentHint = True ,
@@ -110,7 +126,8 @@ async def update_instance_memory(instance_id: str, memory: int) -> dict:
110126 result = await aura_manager .update_instance_memory (instance_id , memory )
111127 return result
112128
113- @mcp .tool (annotations = ToolAnnotations (title = "Update Instance Vector Optimization" ,
129+ @mcp .tool (name = namespace_prefix + "update_instance_vector_optimization" ,
130+ annotations = ToolAnnotations (title = "Update Instance Vector Optimization" ,
114131 readOnlyHint = False ,
115132 destructiveHint = True ,
116133 idempotentHint = True ,
@@ -122,7 +139,9 @@ async def update_instance_vector_optimization(instance_id: str, vector_optimized
122139 result = await aura_manager .update_instance_vector_optimization (instance_id , vector_optimized )
123140 return result
124141
125- @mcp .tool (annotations = ToolAnnotations (title = "Pause Instance" ,
142+ @mcp .tool (
143+ name = namespace_prefix + "pause_instance" ,
144+ annotations = ToolAnnotations (title = "Pause Instance" ,
126145 readOnlyHint = False ,
127146 destructiveHint = False ,
128147 idempotentHint = True ,
@@ -134,7 +153,9 @@ async def pause_instance(instance_id: str) -> dict:
134153 result = await aura_manager .pause_instance (instance_id )
135154 return result
136155
137- @mcp .tool (annotations = ToolAnnotations (title = "Resume Instance" ,
156+ @mcp .tool (
157+ name = namespace_prefix + "resume_instance" ,
158+ annotations = ToolAnnotations (title = "Resume Instance" ,
138159 readOnlyHint = False ,
139160 destructiveHint = False ,
140161 idempotentHint = True ,
@@ -146,7 +167,10 @@ async def resume_instance(instance_id: str) -> dict:
146167 result = await aura_manager .resume_instance (instance_id )
147168 return result
148169
149- @mcp .tool (annotations = ToolAnnotations (title = "List Tenants" ,
170+
171+ @mcp .tool (
172+ name = namespace_prefix + "list_tenants" ,
173+ annotations = ToolAnnotations (title = "List Tenants" ,
150174 readOnlyHint = True ,
151175 destructiveHint = False ,
152176 idempotentHint = True ,
@@ -158,7 +182,9 @@ async def list_tenants() -> dict:
158182 result = await aura_manager .list_tenants ()
159183 return result
160184
161- @mcp .tool (annotations = ToolAnnotations (title = "Get Tenant Details" ,
185+ @mcp .tool (
186+ name = namespace_prefix + "get_tenant_details" ,
187+ annotations = ToolAnnotations (title = "Get Tenant Details" ,
162188 readOnlyHint = True ,
163189 destructiveHint = False ,
164190 idempotentHint = True ,
@@ -170,7 +196,8 @@ async def get_tenant_details(tenant_id: str) -> dict:
170196 result = await aura_manager .get_tenant_details (tenant_id )
171197 return result
172198
173- @mcp .tool (annotations = ToolAnnotations (title = "Delete Instance" ,
199+ @mcp .tool (name = namespace_prefix + "delete_instance" ,
200+ annotations = ToolAnnotations (title = "Delete Instance" ,
174201 readOnlyHint = False ,
175202 destructiveHint = True ,
176203 idempotentHint = True ,
@@ -189,6 +216,7 @@ async def main(
189216 client_id : str ,
190217 client_secret : str ,
191218 transport : Literal ["stdio" , "sse" , "http" ] = "stdio" ,
219+ namespace : str = "" ,
192220 host : str = "127.0.0.1" ,
193221 port : int = 8000 ,
194222 path : str = "/mcp/" ,
@@ -209,9 +237,9 @@ async def main(
209237 Middleware (TrustedHostMiddleware ,
210238 allowed_hosts = allowed_hosts )
211239 ]
212-
240+
213241 # Create MCP server
214- mcp = create_mcp_server (aura_manager )
242+ mcp = create_mcp_server (aura_manager , namespace )
215243
216244 # Run the server with the specified transport
217245 match transport :
0 commit comments