-
Notifications
You must be signed in to change notification settings - Fork 9
fix: APIError now inherits from Exception instead of BaseModel #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pepo1275
wants to merge
4
commits into
ComputingVictor:main
Choose a base branch
from
pepo1275:develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f8c1d65
feat: add CI/CD workflows and project documentation
11599ee
feat: add testing framework and improve .gitignore
c4d1362
feat: add RPVEA-BOE testing framework with conformity/quality distinc…
c41ece2
fix: APIError now inherits from Exception instead of BaseModel
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ## Descripción | ||
| <!-- Qué cambios incluye este PR --> | ||
|
|
||
| ## Tipo de cambio | ||
| - [ ] Feature (nueva funcionalidad) | ||
| - [ ] Bugfix (corrección de error) | ||
| - [ ] Hotfix (corrección urgente) | ||
| - [ ] Docs (documentación) | ||
| - [ ] Refactor (sin cambio funcional) | ||
|
|
||
| ## Checklist | ||
| - [ ] Tests añadidos/actualizados | ||
| - [ ] Documentación actualizada | ||
| - [ ] `black` y `flake8` pasan | ||
| - [ ] Funciona con la API del BOE | ||
|
|
||
| ## Testing | ||
| <!-- Cómo se ha probado este cambio --> | ||
|
|
||
| ## Notas adicionales | ||
| <!-- Cualquier información relevante para los revisores --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: pip | ||
| directory: "/" | ||
| schedule: | ||
| interval: weekly | ||
| open-pull-requests-limit: 5 | ||
| labels: | ||
| - dependencies | ||
| - python | ||
|
|
||
| - package-ecosystem: github-actions | ||
| directory: "/" | ||
| schedule: | ||
| interval: weekly | ||
| open-pull-requests-limit: 5 | ||
| labels: | ||
| - dependencies | ||
| - github-actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, develop] | ||
| pull_request: | ||
| branches: [main, develop] | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: Install dependencies | ||
| run: pip install -e ".[dev]" | ||
| - name: Check formatting with Black | ||
| run: python -m black --check src/ | ||
| - name: Lint with flake8 | ||
| run: python -m flake8 src/ | ||
| - name: Type check with mypy | ||
| run: python -m mypy src/ | ||
|
|
||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ['3.8', '3.10', '3.11', '3.12'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: pip install -e ".[test]" | ||
| - name: Run tests with coverage | ||
| run: python -m pytest tests/ -v --cov=src/mcp_boe --cov-report=xml | ||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v4 | ||
| if: matrix.python-version == '3.11' | ||
| with: | ||
| fail_ci_if_error: false | ||
|
|
||
| connectivity: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: Install dependencies | ||
| run: pip install -e . | ||
| - name: Test BOE API connectivity | ||
| run: python examples/basic_usage.py connectivity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: Install build tools | ||
| run: pip install build twine | ||
| - name: Build package | ||
| run: python -m build | ||
| - name: Publish to PyPI | ||
| run: twine upload dist/* | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,59 @@ | ||
| # Python | ||
| *.pyc | ||
| __pycache__/ | ||
| __pycache__/ | ||
| *.pyo | ||
| *.pyd | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
|
|
||
| # Virtual environments | ||
| venv/ | ||
| env/ | ||
| .venv/ | ||
| .env/ | ||
|
|
||
| # IDE | ||
| .idea/ | ||
| .vscode/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| .DS_Store? | ||
| ._* | ||
| .Spotlight-V100 | ||
| .Trashes | ||
| ehthumbs.db | ||
| Thumbs.db | ||
|
|
||
| # Testing | ||
| .pytest_cache/ | ||
| .coverage | ||
| htmlcov/ | ||
| .tox/ | ||
| .nox/ | ||
| coverage.xml | ||
| *.cover | ||
| *.py,cover | ||
|
|
||
| # Mypy | ||
| .mypy_cache/ | ||
|
|
||
| # Local scripts (not part of the project) | ||
| crear_estructura_testing.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| MCP-BOE is a Model Context Protocol (MCP) server that provides access to the Spanish Official State Gazette (BOE - Boletín Oficial del Estado) API. It allows LLMs like Claude to search consolidated legislation, daily BOE/BORME summaries, and auxiliary reference tables. | ||
|
|
||
| ## Build & Development Commands | ||
|
|
||
| ```bash | ||
| # Install for development | ||
| pip install -e ".[dev]" | ||
|
|
||
| # Install with REST API support | ||
| pip install -e ".[api]" | ||
|
|
||
| # Run the MCP server | ||
| python -m mcp_boe.server | ||
|
|
||
| # Server modes | ||
| python -m mcp_boe.server --mode server # Run MCP server (default) | ||
| python -m mcp_boe.server --mode test # Run test function | ||
| python -m mcp_boe.server --mode diagnose # Diagnose API connectivity | ||
|
|
||
| # Test connectivity | ||
| python examples/basic_usage.py connectivity | ||
|
|
||
| # Run all tests | ||
| python examples/basic_usage.py all | ||
|
|
||
| # Run specific tests | ||
| python examples/basic_usage.py search # Legislation search | ||
| python examples/basic_usage.py summary # BOE summaries | ||
| python examples/basic_usage.py departments # Auxiliary tables | ||
|
|
||
| # Start REST API wrapper | ||
| python rest_api_wrapper.py | ||
|
|
||
| # Linting and formatting | ||
| python -m black src/ | ||
| python -m flake8 src/ | ||
| python -m mypy src/ | ||
|
|
||
| # Run pytest | ||
| python -m pytest tests/ | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Core Components | ||
|
|
||
| - **`src/mcp_boe/server.py`**: Main MCP server (`BOEMCPServer`) that registers tool handlers and coordinates communication with MCP clients. Entry point is `main()`. | ||
|
|
||
| - **`src/mcp_boe/utils/http_client.py`**: `BOEHTTPClient` - async HTTP client for BOE API with retry logic, timeout handling, and XML/JSON parsing. Base URL: `https://www.boe.es/datosabiertos/api` | ||
|
|
||
| - **`src/mcp_boe/tools/`**: MCP tool implementations, each class provides `get_tools()` returning tool definitions and async methods for tool execution: | ||
| - `legislation.py` - `LegislationTools`: Search and retrieve consolidated legislation | ||
| - `summaries.py` - `SummaryTools`: BOE/BORME daily summaries | ||
| - `auxiliary.py` - `AuxiliaryTools`: Reference tables (departments, legal ranges, matters) | ||
|
|
||
| - **`src/mcp_boe/models/boe_models.py`**: Pydantic models and validation helpers (`validate_boe_identifier`, `validate_date_format`) | ||
|
|
||
| ### Tool Registration Pattern | ||
|
|
||
| Tools are registered in `BOEMCPServer._setup_handlers()` via `@self.server.list_tools()` and `@self.server.call_tool()` decorators. Each tool class implements: | ||
| 1. `get_tools()` - Returns list of `mcp.types.Tool` with JSON Schema input definitions | ||
| 2. Async handler methods that return `List[TextContent]` | ||
|
|
||
| ### API Endpoints Used | ||
|
|
||
| ``` | ||
| /legislacion-consolidada - Legislation search and retrieval | ||
| /boe/sumario/{date} - BOE daily summaries | ||
| /borme/sumario/{date} - BORME daily summaries | ||
| /tablas-auxiliares/{table} - Auxiliary tables (departamentos, rangos, materias, etc.) | ||
| ``` | ||
|
|
||
| ### Key Identifiers | ||
|
|
||
| - BOE document IDs: `BOE-A-YYYY-NNNNN` (e.g., `BOE-A-2015-10566`) | ||
| - Date format: `YYYYMMDD` (e.g., `20240529`) | ||
| - Department codes: 4-digit strings (e.g., `7723` for Jefatura del Estado) | ||
| - Legal range codes: 4-digit strings (e.g., `1300` for Ley, `1200` for Real Decreto) | ||
|
|
||
| ## Configuration | ||
|
|
||
| Environment variables for advanced configuration (see `BOEMCPConfig`): | ||
| - `BOE_HTTP_TIMEOUT`: Request timeout (default: 30s) | ||
| - `BOE_MAX_RETRIES`: Max retry attempts (default: 3) | ||
| - `BOE_RETRY_DELAY`: Delay between retries (default: 1s) | ||
| - `LOG_LEVEL`: Logging level (default: INFO) | ||
|
|
||
| ## MCP Client Configuration | ||
|
|
||
| For Claude Code with uvx: | ||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "mcp-boe": { | ||
| "command": "uvx", | ||
| "args": ["--from", "git+https://github.com/ComputingVictor/MCP-BOE.git", "mcp-boe"], | ||
| "transport": "stdio" | ||
| } | ||
| } | ||
| } | ||
| ``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File not needed for this repository. Please remove it. Many Thanks!!