Conversation
WalkthroughThis update introduces a new documentation template file, ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
metabase_mcp_server/app.py (1)
217-231: Add a docstring for better documentation.The resource implementation is correct and follows MCP patterns well. The async file reading with proper path resolution is appropriate.
Consider adding a docstring to the function for better documentation:
@mcp.resource( uri="resource://database_knowledge_base", name="database_knowledge_base", description=""" Provides documentation about database schema, tables, fields and their relationships. """, ) async def database_knowledge_base() -> str: + """Read and return the contents of the database knowledge base markdown file.""" path = ( Path(__file__).parent.parent / "database_knowledge_base.md" ).resolve() async with aiofiles.open(path) as file: content = await file.read() return content🧰 Tools
🪛 Pylint (3.3.7)
[convention] 225-225: Missing function or method docstring
(C0116)
tests/test_app.py (1)
178-186: Excellent test coverage for the new resource.The test properly validates the database knowledge base resource by comparing the returned content with the actual file content. The path construction matches the implementation, ensuring consistency.
Consider adding a docstring for consistency with other test functions:
async def test_database_knowledge_base(client: Client) -> None: + """Test that the database knowledge base resource returns the correct markdown content.""" response = await client.read_resource("resource://database_knowledge_base")🧰 Tools
🪛 Pylint (3.3.7)
[convention] 178-178: Missing function or method docstring
(C0116)
database_knowledge_base.md (3)
12-14: Suggest clarifying example database details.Remind users to update both
database_idand engine name to match their own Redshift (or alternative) environment. You could parameterize these values or link to your deployment manifest for consistency.
15-22: Recommend marking key relationships in example tables.Listing tables and columns is helpful; consider annotating primary keys, foreign keys, and index recommendations in real‐world templates to guide schema design and query performance.
24-24: Refine phrasing for countable nouns.LanguageTool flags “amount of bookings” since bookings are countable. Consider:
- For customer activity profiles: calculate the average total_amount of bookings in the customer's first month. + For customer activity profiles: calculate the average booking amount in the customer's first month.🧰 Tools
🪛 LanguageTool
[uncategorized] ~24-~24: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...y profiles: calculate the average total_amount of bookings in the customer's first mon...(AMOUNTOF_TO_NUMBEROF)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (5)
README.md(2 hunks)database_knowledge_base.md(1 hunks)metabase_mcp_server/app.py(2 hunks)pyproject.toml(2 hunks)tests/test_app.py(2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
`**/*.py`: Enforce Relative Imports for Internal Modules
Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module dir...
**/*.py: Enforce Relative Imports for Internal ModulesEnsure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.
Examples and Guidelines:
- If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
- If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
- If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
- External (third-party) libraries should be imported absolutely (e.g., import requests).
metabase_mcp_server/app.pytests/test_app.py
`**/*.py`:
Rule: Enforce Snake Case in Python Backend
- New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
- Exceptions (Pydantic...
**/*.py:
Rule: Enforce Snake Case in Python Backend
- New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
- Exceptions (Pydantic models for API responses):
- Primary fields must be snake_case.
- If older clients expect camelCase, create a computed or alias field that references the snake_case field.
- Mark any camelCase fields as deprecated or transitional.
Examples
Invalid:
class CardConfiguration(BaseModel): title: str subTitle: str # ❌ Modified or new field in camelCaseValid:
class CardConfiguration(BaseModel): title: str subtitle: str # ✅ snake_case for new/modified field @computed_field def subTitle(self) -> str: # camelCase allowed only for compatibility return self.subtitleAny direct use of camelCase in new or updated code outside of these exceptions should be flagged.
metabase_mcp_server/app.pytests/test_app.py
`**/*.py`: Use try/except for concise error handling when accessing nested dictionary keys:
try:
can_ignore_error = data['error']['code'] in ignore_error_codes
excep...</summary>
> `**/*.py`: Use try/except for concise error handling when accessing nested dictionary keys:
>
> ```python
> try:
> can_ignore_error = data['error']['code'] in ignore_error_codes
> except KeyError:
> can_ignore_error = False
> ```
>
> ❌ Avoid Verbose Chained Conditionals:
> ```python
> can_ignore_error = (
> 'code' in data['error']
> and data['error']['code'] in ignore_error_codes
> )
> ```
>
> Explanation:
> The try/except approach:
>
> Reduces code complexity and nesting
> Improves readability by focusing on the "happy path" logic
> Follows Python's "easier to ask forgiveness than permission" (EAFP) idiom
>
> Severity: Important (Not a Nitpick)
> This pattern significantly improves code maintainability and readability, especially as dictionary access patterns become more complex.
- `metabase_mcp_server/app.py`
- `tests/test_app.py`
</details>
<details>
<summary>`**/*.py`: Context
Agave is our internal Python library for processing SQS messages. The @task decorator can automatically convert JSON to Pydantic models.
Rule
Always annotate @t...</summary>
> `**/*.py`: Context
> Agave is our internal Python library for processing SQS messages. The @task decorator can automatically convert JSON to Pydantic models.
>
> Rule
> Always annotate @task parameters with Pydantic models instead of manually converting dictionaries.
>
> Correct Pattern
> ```python
> from pydantic import BaseModel
> from agave.tasks.sqs_tasks import task
>
> class User(BaseModel):
> name: str
> age: int
>
> @task(queue_url=QUEUE_URL, region_name='us-east-1')
> async def task_validator(message: User) -> None:
> # The message is already a User instance - no conversion needed
> print(message.name) # Direct attribute access
> ```
>
> Incorrect Pattern
> ```python
> from pydantic import BaseModel
> from agave.tasks.sqs_tasks import task
>
> class User(BaseModel):
> name: str
> age: int
>
> @task(queue_url=QUEUE_URL, region_name='us-east-1')
> async def task_validator(message_data: dict) -> None: # or unannotated parameter
> # Unnecessary conversion
> message = User(**message_data)
> print(message.name)
> ```
>
> Explanation
> The Agave @task decorator automatically:
>
> - Reads JSON messages from SQS queues
> - Converts them to Pydantic model instances when the handler parameter is annotated
> - Performs validation based on the Pydantic model
- `metabase_mcp_server/app.py`
- `tests/test_app.py`
</details>
<details>
<summary>`**/*.py`: ## MANDATORY: Use built-in Pydantic validators
### Description
Avoid creating custom validators that duplicate functionality already provided by Pydantic's built-in val...</summary>
> `**/*.py`: ## MANDATORY: Use built-in Pydantic validators
>
> ### Description
> Avoid creating custom validators that duplicate functionality already provided by Pydantic's built-in validators, pydantic_extra_types package, or third-party Pydantic validator libraries. This improves code maintainability and reduces unnecessary unit tests.
>
> ### Bad Practice
> ```python
> from pydantic import BaseModel, field_validator
>
> class MyValidator(BaseModel):
> location: str
>
> @field_validator('location')
> def validate_location(cls, value: str) -> str:
> values = value.split(',')
> if len(values) != 3:
> raise ValueError('Must provide exactly 3 values for location')
> # Custom validation logic that duplicates functionality
> return value
> ```
>
> ### Good Practice
> ```python
> from pydantic import BaseModel
> from pydantic_extra_types.coordinate import Coordinate
>
> class MyValidator(BaseModel):
> location: Coordinate
> ```
>
> ### Unit Test Guidelines
> Do not write unit tests specifically for validating the behavior of Pydantic's built-in validators. These are already well-tested by the Pydantic library itself.
>
> #### Tests to Remove
> ```python
> def test_invalid_location():
> pytest.raises(ValidationError):
> MyValidator(location='foo,bar')
> ```
>
> ### Rule Enforcement
> This is a mandatory rule, not a refactoring suggestion. Changes must be implemented when:
> 1. A custom validator replicates functionality already available in Pydantic's ecosystem
> 2. There is a suitable built-in, pydantic_extra_types, or third-party Pydantic validator available
>
> Actions required:
> 1. Replace custom validators with appropriate existing validators
> 2. Remove unnecessary unit tests that only validate built-in Pydantic validation behavior
> 3. Block PRs that introduce new custom validators when alternatives exist
- `metabase_mcp_server/app.py`
- `tests/test_app.py`
</details>
</details><details>
<summary>🧬 Code Graph Analysis (1)</summary>
<details>
<summary>tests/test_app.py (1)</summary><blockquote>
<details>
<summary>tests/conftest.py (1)</summary>
* `client` (16-18)
</details>
</blockquote></details>
</details><details>
<summary>🪛 LanguageTool</summary>
<details>
<summary>database_knowledge_base.md</summary>
[uncategorized] ~24-~24: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...y profiles: calculate the average total_amount of bookings in the customer's first mon...
(AMOUNTOF_TO_NUMBEROF)
</details>
</details>
<details>
<summary>🪛 Pylint (3.3.7)</summary>
<details>
<summary>metabase_mcp_server/app.py</summary>
[error] 11-11: Unable to import 'aiofiles'
(E0401)
---
[convention] 225-225: Missing function or method docstring
(C0116)
</details>
<details>
<summary>tests/test_app.py</summary>
[error] 4-4: Unable to import 'aiofiles'
(E0401)
---
[error] 6-6: Unable to import 'fastmcp'
(E0401)
---
[error] 7-7: Unable to import 'mcp.types'
(E0401)
---
[convention] 178-178: Missing function or method docstring
(C0116)
</details>
</details>
</details>
<details>
<summary>🔇 Additional comments (8)</summary><blockquote>
<details>
<summary>pyproject.toml (1)</summary>
`8-8`: **LGTM! Proper dependency management for async file operations.**
The addition of `aiofiles` and its type stubs appropriately supports the new asynchronous file reading functionality in the database knowledge base resource.
Also applies to: 20-20
</details>
<details>
<summary>README.md (1)</summary>
`5-5`: **Excellent documentation updates.**
The section reorganization and new Resources documentation clearly communicate the available functionality. The customization note is particularly helpful for users to understand they need to modify the knowledge base file for their specific use case.
Also applies to: 14-19
</details>
<details>
<summary>metabase_mcp_server/app.py (1)</summary>
`7-7`: **LGTM! Proper imports for the new functionality.**
The Path and aiofiles imports are correctly added to support the asynchronous file reading in the new resource.
Also applies to: 11-11
</details>
<details>
<summary>tests/test_app.py (1)</summary>
`2-2`: **LGTM! Proper test imports added.**
The new imports support testing the database knowledge base resource functionality correctly.
Also applies to: 4-4, 7-7
</details>
<details>
<summary>database_knowledge_base.md (4)</summary>
`1-4`: **Approve header and admonition clarity.**
The top-level heading and blockquote clearly identify this as a template and strongly emphasize the need for customization before production use.
---
`5-11`: **Approve guidelines section.**
The bullet points provide concise, actionable steps for using Metabase effectively—checking existing questions, verifying schemas, normalizing dates, and testing queries.
---
`23-26`: **Approve Additional Notes examples.**
The business logic snippets (first-month averages, excluding cancellations) are insightful. Ensure you extend them with edge cases like refunds or partial charges when adapting to your domain.
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 LanguageTool</summary>
[uncategorized] ~24-~24: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...y profiles: calculate the average total_amount of bookings in the customer's first mon...
(AMOUNTOF_TO_NUMBEROF)
</details>
</details>
---
`27-28`: **Approve call-to-action.**
The final reminder to replace all example names and rules is clear and prominently placed, ensuring users won’t overlook customization.
</details>
</blockquote></details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
try:
can_ignore_error = data['error']['code'] in ignore_error_codes
excep...</summary>
> `**/*.py`: Use try/except for concise error handling when accessing nested dictionary keys:
>
> ```python
> try:
> can_ignore_error = data['error']['code'] in ignore_error_codes
> except KeyError:
> can_ignore_error = False
> ```
>
> ❌ Avoid Verbose Chained Conditionals:
> ```python
> can_ignore_error = (
> 'code' in data['error']
> and data['error']['code'] in ignore_error_codes
> )
> ```
>
> Explanation:
> The try/except approach:
>
> Reduces code complexity and nesting
> Improves readability by focusing on the "happy path" logic
> Follows Python's "easier to ask forgiveness than permission" (EAFP) idiom
>
> Severity: Important (Not a Nitpick)
> This pattern significantly improves code maintainability and readability, especially as dictionary access patterns become more complex.
- `metabase_mcp_server/app.py`
- `tests/test_app.py`
</details>
<details>
<summary>`**/*.py`: Context
Agave is our internal Python library for processing SQS messages. The @task decorator can automatically convert JSON to Pydantic models.
Rule
Always annotate @t...</summary>
> `**/*.py`: Context
> Agave is our internal Python library for processing SQS messages. The @task decorator can automatically convert JSON to Pydantic models.
>
> Rule
> Always annotate @task parameters with Pydantic models instead of manually converting dictionaries.
>
> Correct Pattern
> ```python
> from pydantic import BaseModel
> from agave.tasks.sqs_tasks import task
>
> class User(BaseModel):
> name: str
> age: int
>
> @task(queue_url=QUEUE_URL, region_name='us-east-1')
> async def task_validator(message: User) -> None:
> # The message is already a User instance - no conversion needed
> print(message.name) # Direct attribute access
> ```
>
> Incorrect Pattern
> ```python
> from pydantic import BaseModel
> from agave.tasks.sqs_tasks import task
>
> class User(BaseModel):
> name: str
> age: int
>
> @task(queue_url=QUEUE_URL, region_name='us-east-1')
> async def task_validator(message_data: dict) -> None: # or unannotated parameter
> # Unnecessary conversion
> message = User(**message_data)
> print(message.name)
> ```
>
> Explanation
> The Agave @task decorator automatically:
>
> - Reads JSON messages from SQS queues
> - Converts them to Pydantic model instances when the handler parameter is annotated
> - Performs validation based on the Pydantic model
- `metabase_mcp_server/app.py`
- `tests/test_app.py`
</details>
<details>
<summary>`**/*.py`: ## MANDATORY: Use built-in Pydantic validators
### Description
Avoid creating custom validators that duplicate functionality already provided by Pydantic's built-in val...</summary>
> `**/*.py`: ## MANDATORY: Use built-in Pydantic validators
>
> ### Description
> Avoid creating custom validators that duplicate functionality already provided by Pydantic's built-in validators, pydantic_extra_types package, or third-party Pydantic validator libraries. This improves code maintainability and reduces unnecessary unit tests.
>
> ### Bad Practice
> ```python
> from pydantic import BaseModel, field_validator
>
> class MyValidator(BaseModel):
> location: str
>
> @field_validator('location')
> def validate_location(cls, value: str) -> str:
> values = value.split(',')
> if len(values) != 3:
> raise ValueError('Must provide exactly 3 values for location')
> # Custom validation logic that duplicates functionality
> return value
> ```
>
> ### Good Practice
> ```python
> from pydantic import BaseModel
> from pydantic_extra_types.coordinate import Coordinate
>
> class MyValidator(BaseModel):
> location: Coordinate
> ```
>
> ### Unit Test Guidelines
> Do not write unit tests specifically for validating the behavior of Pydantic's built-in validators. These are already well-tested by the Pydantic library itself.
>
> #### Tests to Remove
> ```python
> def test_invalid_location():
> pytest.raises(ValidationError):
> MyValidator(location='foo,bar')
> ```
>
> ### Rule Enforcement
> This is a mandatory rule, not a refactoring suggestion. Changes must be implemented when:
> 1. A custom validator replicates functionality already available in Pydantic's ecosystem
> 2. There is a suitable built-in, pydantic_extra_types, or third-party Pydantic validator available
>
> Actions required:
> 1. Replace custom validators with appropriate existing validators
> 2. Remove unnecessary unit tests that only validate built-in Pydantic validation behavior
> 3. Block PRs that introduce new custom validators when alternatives exist
- `metabase_mcp_server/app.py`
- `tests/test_app.py`
</details>
</details><details>
<summary>🧬 Code Graph Analysis (1)</summary>
<details>
<summary>tests/test_app.py (1)</summary><blockquote>
<details>
<summary>tests/conftest.py (1)</summary>
* `client` (16-18)
</details>
</blockquote></details>
</details><details>
<summary>🪛 LanguageTool</summary>
<details>
<summary>database_knowledge_base.md</summary>
[uncategorized] ~24-~24: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...y profiles: calculate the average total_amount of bookings in the customer's first mon...
(AMOUNTOF_TO_NUMBEROF)
</details>
</details>
<details>
<summary>🪛 Pylint (3.3.7)</summary>
<details>
<summary>metabase_mcp_server/app.py</summary>
[error] 11-11: Unable to import 'aiofiles'
(E0401)
---
[convention] 225-225: Missing function or method docstring
(C0116)
</details>
<details>
<summary>tests/test_app.py</summary>
[error] 4-4: Unable to import 'aiofiles'
(E0401)
---
[error] 6-6: Unable to import 'fastmcp'
(E0401)
---
[error] 7-7: Unable to import 'mcp.types'
(E0401)
---
[convention] 178-178: Missing function or method docstring
(C0116)
</details>
</details>
</details>
<details>
<summary>🔇 Additional comments (8)</summary><blockquote>
<details>
<summary>pyproject.toml (1)</summary>
`8-8`: **LGTM! Proper dependency management for async file operations.**
The addition of `aiofiles` and its type stubs appropriately supports the new asynchronous file reading functionality in the database knowledge base resource.
Also applies to: 20-20
</details>
<details>
<summary>README.md (1)</summary>
`5-5`: **Excellent documentation updates.**
The section reorganization and new Resources documentation clearly communicate the available functionality. The customization note is particularly helpful for users to understand they need to modify the knowledge base file for their specific use case.
Also applies to: 14-19
</details>
<details>
<summary>metabase_mcp_server/app.py (1)</summary>
`7-7`: **LGTM! Proper imports for the new functionality.**
The Path and aiofiles imports are correctly added to support the asynchronous file reading in the new resource.
Also applies to: 11-11
</details>
<details>
<summary>tests/test_app.py (1)</summary>
`2-2`: **LGTM! Proper test imports added.**
The new imports support testing the database knowledge base resource functionality correctly.
Also applies to: 4-4, 7-7
</details>
<details>
<summary>database_knowledge_base.md (4)</summary>
`1-4`: **Approve header and admonition clarity.**
The top-level heading and blockquote clearly identify this as a template and strongly emphasize the need for customization before production use.
---
`5-11`: **Approve guidelines section.**
The bullet points provide concise, actionable steps for using Metabase effectively—checking existing questions, verifying schemas, normalizing dates, and testing queries.
---
`23-26`: **Approve Additional Notes examples.**
The business logic snippets (first-month averages, excluding cancellations) are insightful. Ensure you extend them with edge cases like refunds or partial charges when adapting to your domain.
<details>
<summary>🧰 Tools</summary>
<details>
<summary>🪛 LanguageTool</summary>
[uncategorized] ~24-~24: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...y profiles: calculate the average total_amount of bookings in the customer's first mon...
(AMOUNTOF_TO_NUMBEROF)
</details>
</details>
---
`27-28`: **Approve call-to-action.**
The final reminder to replace all example names and rules is clear and prominently placed, ensuring users won’t overlook customization.
</details>
</blockquote></details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
Summary by CodeRabbit