Fix BaseService constructor inheritance and MCP server initialization
- Fix service constructors to properly call BaseService with required name parameter - Fix AuthService, UserService, and SettingsService constructor signatures - Add missing ServerCapabilities to MCP server initialization - Create main_sync() wrapper function for script entry point compatibility - Update pyproject.toml to use synchronous entry point for uvx/pip execution Resolves BaseService.__init__() missing required positional argument error All execution methods now work correctly: npx, uvx, pip, python -m 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
be1e05c382
commit
7c32d69f2d
@ -55,7 +55,7 @@ Repository = "https://github.com/portainer/portainer-mcp-core"
|
|||||||
Issues = "https://github.com/portainer/portainer-mcp-core/issues"
|
Issues = "https://github.com/portainer/portainer-mcp-core/issues"
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
portainer-core-mcp = "portainer_core.server:main"
|
portainer-core-mcp = "portainer_core.server:main_sync"
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
where = ["src"]
|
where = ["src"]
|
||||||
|
@ -17,6 +17,9 @@ from mcp.types import (
|
|||||||
TextContent,
|
TextContent,
|
||||||
ImageContent,
|
ImageContent,
|
||||||
EmbeddedResource,
|
EmbeddedResource,
|
||||||
|
ServerCapabilities,
|
||||||
|
ResourcesCapability,
|
||||||
|
ToolsCapability,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .config import get_global_config, get_global_server_config
|
from .config import get_global_config, get_global_server_config
|
||||||
@ -1148,6 +1151,15 @@ class PortainerCoreMCPServer:
|
|||||||
InitializationOptions(
|
InitializationOptions(
|
||||||
server_name=server_config.server_name,
|
server_name=server_config.server_name,
|
||||||
server_version=server_config.version,
|
server_version=server_config.version,
|
||||||
|
capabilities=ServerCapabilities(
|
||||||
|
resources=ResourcesCapability(
|
||||||
|
subscribe=True,
|
||||||
|
list_changed=True,
|
||||||
|
),
|
||||||
|
tools=ToolsCapability(
|
||||||
|
list_changed=True,
|
||||||
|
),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -1260,5 +1272,15 @@ async def main() -> None:
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main_sync() -> None:
|
||||||
|
"""
|
||||||
|
Synchronous entry point for the server.
|
||||||
|
|
||||||
|
This function is used by the script entry point in pyproject.toml.
|
||||||
|
It wraps the async main() function with asyncio.run().
|
||||||
|
"""
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main_sync()
|
@ -23,8 +23,8 @@ from ..utils.logging import get_logger
|
|||||||
class AuthService(BaseService):
|
class AuthService(BaseService):
|
||||||
"""Service for authentication operations."""
|
"""Service for authentication operations."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__("auth")
|
||||||
self.logger = get_logger(__name__)
|
self.logger = get_logger(__name__)
|
||||||
self._cached_token = None
|
self._cached_token = None
|
||||||
self._token_expires_at = None
|
self._token_expires_at = None
|
||||||
|
@ -19,8 +19,8 @@ from ..utils.logging import get_logger
|
|||||||
class SettingsService(BaseService):
|
class SettingsService(BaseService):
|
||||||
"""Service for settings management operations."""
|
"""Service for settings management operations."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__("settings")
|
||||||
self.logger = get_logger(__name__)
|
self.logger = get_logger(__name__)
|
||||||
|
|
||||||
async def get_settings(self) -> SettingsResponse:
|
async def get_settings(self) -> SettingsResponse:
|
||||||
|
@ -25,8 +25,8 @@ from ..utils.logging import get_logger
|
|||||||
class UserService(BaseService):
|
class UserService(BaseService):
|
||||||
"""Service for user management operations."""
|
"""Service for user management operations."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__("users")
|
||||||
self.logger = get_logger(__name__)
|
self.logger = get_logger(__name__)
|
||||||
|
|
||||||
async def list_users(self) -> List[UserResponse]:
|
async def list_users(self) -> List[UserResponse]:
|
||||||
|
Loading…
Reference in New Issue
Block a user