fix: correct FastMCP interface usage and resolve lint issues

- Fix FastMCP server interface to use correct mcp.run() instead of app.run(host, port)
- Remove unnecessary host and port parameters, use standard STDIO transport
- Fix all ruff lint issues including import sorting and blank lines
- Update ruff configuration to new lint configuration format
- Fix type annotation issues using Union syntax (int | None)
- Ensure uvx pypi-query-mcp-server works correctly
- All tests pass and lint checks pass
This commit is contained in:
longhao 2025-05-27 11:25:25 +08:00 committed by Hal
parent 030b3a2607
commit 576652571c
12 changed files with 38 additions and 51 deletions

View file

@ -13,22 +13,22 @@ def test_version():
def test_import():
"""Test that main modules can be imported."""
from pypi_query_mcp.core import PyPIClient, VersionCompatibility
from pypi_query_mcp.server import app
from pypi_query_mcp.server import mcp
assert PyPIClient is not None
assert VersionCompatibility is not None
assert app is not None
assert mcp is not None
@pytest.mark.asyncio
async def test_pypi_client_basic():
"""Test basic PyPI client functionality."""
from pypi_query_mcp.core import PyPIClient
async with PyPIClient() as client:
# Test that client can be created and closed
assert client is not None
# Test cache clearing
client.clear_cache()
@ -36,24 +36,24 @@ async def test_pypi_client_basic():
def test_version_compatibility():
"""Test version compatibility utility."""
from pypi_query_mcp.core import VersionCompatibility
compat = VersionCompatibility()
# Test requires_python parsing
spec = compat.parse_requires_python(">=3.8")
assert spec is not None
# Test classifier extraction
classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython"
]
versions = compat.extract_python_versions_from_classifiers(classifiers)
assert "3.8" in versions
assert "3.9" in versions
implementations = compat.extract_python_implementations(classifiers)
assert "CPython" in implementations
@ -68,7 +68,7 @@ def test_mcp_tools_import():
query_package_versions,
suggest_python_version_for_packages,
)
# Test that all tools are callable
assert callable(query_package_info)
assert callable(query_package_versions)