Skip to content

feat(#150): add mcp server with extra lgtm-ai[mcp]#151

Merged
scastlara merged 2 commits into
mainfrom
mcp
Oct 1, 2025
Merged

feat(#150): add mcp server with extra lgtm-ai[mcp]#151
scastlara merged 2 commits into
mainfrom
mcp

Conversation

@scastlara

@scastlara scastlara commented Sep 30, 2025

Copy link
Copy Markdown
Collaborator

New script command lgtm-mcp that starts an mcp server ready for AI agents to interact with.

I had to adapt our testing infra to actually test with and without the extra.

You can see that we have an extra elements in the matrix, with values true or false, indicating whether the mcp extra must be tested.

You can see in our pipelines that it tests what we want to test:

tests/mcp/test_server.py::test_lgtm_review_tool PASSED
tests/mcp/test_server.py::test_cli_exits_if_no_mcp SKIPPED (lgtm-ai[...)
tests/mcp/test_server.py::test_lgtm_review_tool SKIPPED (lgtm-ai[mcp...)
tests/mcp/test_server.py::test_cli_exits_if_no_mcp PASSED

Running locally, the mcp is working and (for instance) GitHub copilot on VSCode can use the provided tool:

image image

refs #150

@github-actions

github-actions Bot commented Sep 30, 2025

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
lgtm_ai
   __main__.py1411589%54, 167, 214–216, 234–235, 264–266, 289, 313–314, 316–317
lgtm_ai/mcp
   __init__.py00100% 
   __main__.py39782%4–5, 54, 87, 90–91, 95
TOTAL177314691% 

Tests Skipped Failures Errors Time
231 1 💤 0 ❌ 0 🔥 10.041s ⏱️

@scastlara
scastlara force-pushed the mcp branch 4 times, most recently from 3747154 to b832066 Compare September 30, 2025 09:46
@github-actions github-actions Bot added feature and removed feature labels Sep 30, 2025
@scastlara scastlara self-assigned this Sep 30, 2025
@github-actions github-actions Bot added feature and removed feature labels Sep 30, 2025
def cli() -> None:
"""Entry point for the MCP tool."""
warnings.warn(
"The lgtm-mcp CLI is experimental and may change in future releases.", category=UserWarning, stacklevel=1

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this CLI undocumented, so that we are free to break it as we want.
Once it's stable, we can remove warnings and add it to the docs.

@sdn4z sdn4z Oct 1, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it still has better documentation than most open source projects though

@scastlara

Copy link
Copy Markdown
Collaborator Author

/lgtm review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦉 lgtm Review

Score: Needs Work 🔧

🔍 Summary

Overall, this is a great PR that successfully adds the requested MCP server functionality. The approach of using an optional extra is well-implemented, and the corresponding changes to the CI/CD pipeline to test both scenarios (with and without [mcp]) are excellent. The new code is also well-structured and includes appropriate tests.

I have found one major issue that needs to be addressed before this can be merged:

  • The MCP server currently does not load configuration from the repository being reviewed (e.g., from a .lgtm-ai.toml file). This means repository-specific settings like model choice, excluded files, and custom prompts will be ignored, which is likely not the desired behavior.

I have also left a couple of minor comments for further improvement. Once the configuration loading is addressed, this PR should be in good shape. Great work!

More information
  • Id: 403900f66ff844c9a7d7f49fe97950d5
  • Model: gemini-2.5-pro
  • Created at: 2025-09-30T14:52:39.833505+00:00
Usage summary
  • Request count: 2
  • Request tokens: 48,534
  • Response tokens: 12,554
  • Total tokens: 61,088

See the 📚 lgtm-ai repository for more information about lgtm.

Comment thread src/lgtm_ai/mcp/__main__.py
Comment thread tests/utils.py Outdated
Comment thread src/lgtm_ai/mcp/__main__.py
scastlara and others added 2 commits October 1, 2025 09:42
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

- name: Install all extras
if: matrix.mcp-extra == true
run: poetry install --all-extras

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: the flag refers only to mcp but all extras will be installed. They're equivalent right now, but worth keeping it in mind.

Not a blocker though

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess we will re-use this step to install+test the version with all extras. I don't foresee we do like all combinations if we end up having more extras.

def cli() -> None:
"""Entry point for the MCP tool."""
warnings.warn(
"The lgtm-mcp CLI is experimental and may change in future releases.", category=UserWarning, stacklevel=1

@sdn4z sdn4z Oct 1, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it still has better documentation than most open source projects though

@scastlara
scastlara merged commit 17b26b2 into main Oct 1, 2025
9 checks passed
@scastlara
scastlara deleted the mcp branch October 3, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants