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"
|
||||
|
||||
[project.scripts]
|
||||
portainer-core-mcp = "portainer_core.server:main"
|
||||
portainer-core-mcp = "portainer_core.server:main_sync"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
|
@ -17,6 +17,9 @@ from mcp.types import (
|
||||
TextContent,
|
||||
ImageContent,
|
||||
EmbeddedResource,
|
||||
ServerCapabilities,
|
||||
ResourcesCapability,
|
||||
ToolsCapability,
|
||||
)
|
||||
|
||||
from .config import get_global_config, get_global_server_config
|
||||
@ -1148,6 +1151,15 @@ class PortainerCoreMCPServer:
|
||||
InitializationOptions(
|
||||
server_name=server_config.server_name,
|
||||
server_version=server_config.version,
|
||||
capabilities=ServerCapabilities(
|
||||
resources=ResourcesCapability(
|
||||
subscribe=True,
|
||||
list_changed=True,
|
||||
),
|
||||
tools=ToolsCapability(
|
||||
list_changed=True,
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
@ -1260,5 +1272,15 @@ async def main() -> None:
|
||||
raise
|
||||
|
||||
|
||||
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())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
main_sync()
|
@ -23,8 +23,8 @@ from ..utils.logging import get_logger
|
||||
class AuthService(BaseService):
|
||||
"""Service for authentication operations."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super().__init__("auth")
|
||||
self.logger = get_logger(__name__)
|
||||
self._cached_token = None
|
||||
self._token_expires_at = None
|
||||
|
@ -19,8 +19,8 @@ from ..utils.logging import get_logger
|
||||
class SettingsService(BaseService):
|
||||
"""Service for settings management operations."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super().__init__("settings")
|
||||
self.logger = get_logger(__name__)
|
||||
|
||||
async def get_settings(self) -> SettingsResponse:
|
||||
|
@ -25,8 +25,8 @@ from ..utils.logging import get_logger
|
||||
class UserService(BaseService):
|
||||
"""Service for user management operations."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
def __init__(self):
|
||||
super().__init__("users")
|
||||
self.logger = get_logger(__name__)
|
||||
|
||||
async def list_users(self) -> List[UserResponse]:
|
||||
|
Loading…
Reference in New Issue
Block a user