8000 feat(cli/mcp): an initial implementation of a lit mcp server package by e111077 · Pull Request #4990 · lit/lit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(cli/mcp): an initial implementation of a lit mcp server package #4990

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

e111077
Copy link
Contributor
@e111077 e111077 commented May 17, 2025

This implements a very basic mcp server that hooks into our algolia search for lit.dev. The key exposed is a rate-limited read-only key.

Features in this pr:

  • Implements an mcp server
    • Tools can have environment compatibilities
      • local can only run when it has source code in front of it or on a local machine
        • e.g. a tool that runs lit analyzer on your code
      • server can only run when it's on a server
        • e.g. a tool potentially set up at an endpoint on something like lit.dev/mcp that might require special API keys etc
      • any can run in any environment
        • e.g. a tool that can run on either local or server like algolia search
    • Only has an algolia search tool right now. Would be cool to eventually search discord
  • Implements the lit labs mcp command
    • Adds this as a labs command on the lit CLI
    • Implement the --skip-permissions command so that AI tools don't get stuck on the cli asking to install the mcp server
Parent Children
#4970

Copy link
Contributor
github-actions bot commented May 17, 2025

📊 Tachometer Benchmark Results

Summary

⏳ Benchmarks are currently running. Results below are out of date.

nop-update

  • this-change, tip-of-tree, previous-release: unsure 🔍 -11% - +8% (-1.50ms - +1.05ms)
    this-change vs tip-of-tree

render

  • this-change: 50.30ms - 67.55ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -3% - +4% (-0.57ms - +0.78ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: faster ✔ 1% - 3% (0.19ms - 1.06ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -24% - +29% (-12.89ms - +15.46ms)
    this-change vs tip-of-tree

update

  • this-change: 486.22ms - 495.84ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -6% - +4% (-2.42ms - +1.76ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -4% - +1% (-3.60ms - +0.78ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +1% (-9.55ms - +3.47ms)
    this-change vs tip-of-tree

update-reflect

  • this-change: 471.85ms - 479.47ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -1% - +2% (-5.53ms - +8.17ms)
    this-change vs tip-of-tree

Results

⏳ Benchmarks are currently running. Results below are out of date.
this-change

render

VersionAvg timevs
50.30ms - 67.55ms-

update

VersionAvg timevs
486.22ms - 495.84ms-

update-reflect

VersionAvg timevs
471.85ms - 479.47ms-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
19.22ms - 20.13ms-unsure 🔍
-3% - +4%
-0.57ms - +0.78ms
unsure 🔍
-3% - +3%
-0.65ms - +0.62ms
tip-of-tree
tip-of-tree
19.08ms - 20.06msunsure 🔍
-4% - +3%
-0.78ms - +0.57ms
-unsure 🔍
-4% - +3%
-0.78ms - +0.54ms
previous-release
previous-release
19.25ms - 20.13msunsure 🔍
-3% - +3%
-0.62ms - +0.65ms
unsure 🔍
-3% - +4%
-0.54ms - +0.78ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
37.63ms - 40.59ms-unsure 🔍
-6% - +4%
-2.42ms - +1.76ms
unsure 🔍
-5% - +5%
-1.82ms - +2.05ms
tip-of-tree
tip-of-tree
37.97ms - 40.92msunsure 🔍
-5% - +6%
-1.76ms - +2.42ms
-unsure 🔍
-4% - +6%
-1.49ms - +2.37ms
previous-release
previous-release
37.75ms - 40.25msunsure 🔍
-5% - +5%
-2.05ms - +1.82ms
unsure 🔍
-6% - +4%
-2.37ms - +1.49ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
11.99ms - 13.75ms-unsure 🔍
-11% - +8%
-1.50ms - +1.05ms
unsure 🔍
-12% - +5%
-1.67ms - +0.75ms
tip-of-tree
tip-of-tree
12.17ms - 14.02msunsure 🔍
-8% - +12%
-1.05ms - +1.50ms
-unsure 🔍
-11% - +7%
-1.47ms - +1.01ms
previous-release
previous-release
12.50ms - 14.15msunsure 🔍
-6% - +13%
-0.75ms - +1.67ms
unsure 🔍
-8% - +11%
-1.01ms - +1.47ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
35.56ms - 36.12ms-faster ✔
1% - 3%
0.19ms - 1.06ms
unsure 🔍
-2% - +1%
-0.56ms - +0.27ms
tip-of-tree
tip-of-tree
36.13ms - 36.80msslower ❌
1% - 3%
0.19ms - 1.06ms
-slower ❌
0% - 3%
0.02ms - 0.93ms
previous-release
previous-release
35.68ms - 36.29msunsure 🔍
-1% - +2%
-0.27ms - +0.56ms
faster ✔
0% - 3%
0.02ms - 0.93ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
77.01ms - 79.81ms-unsure 🔍
-4% - +1%
-3.60ms - +0.78ms
unsure 🔍
-2% - +2%
-1.90ms - +1.83ms
tip-of-tree
tip-of-tree
78.13ms - 81.50msunsure 🔍
-1% - +5%
-0.78ms - +3.60ms
-unsure 🔍
-1% - +4%
-0.72ms - +3.46ms
previous-release
previous-release
77.22ms - 79.68msunsure 🔍
-2% - +2%
-1.83ms - +1.90ms
unsure 🔍
-4% - +1%
-3.46ms - +0.72ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
45.96ms - 66.14ms-unsure 🔍
-24% - +29%
-12.89ms - +15.46ms
unsure 🔍
-27% - +22%
-15.56ms - +12.87ms
tip-of-tree
tip-of-tree
44.81ms - 64.72msunsure 🔍
-27% - +23%
-15.46ms - +12.89ms
-unsure 🔍
-29% - +19%
-16.76ms - +11.49ms
previous-release
previous-release
47.38ms - 67.41msunsure 🔍
-23% - +28%
-12.87ms - +15.56ms
unsure 🔍
-22% - +31%
-11.49ms - +16.76ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
481.32ms - 490.00ms-unsure 🔍
-2% - +1%
-9.55ms - +3.47ms
unsure 🔍
-1% - +2%
-6.54ms - +7.90ms
tip-of-tree
tip-of-tree
483.86ms - 493.56msunsure 🔍
-1% - +2%
-3.47ms - +9.55ms
-unsure 🔍
-1% - +2%
-3.82ms - +11.26ms
previous-release
previous-release
479.22ms - 490.75msunsure 🔍
-2% - +1%
-7.90ms - +6.54ms
unsure 🔍
-2% - +1%
-11.26ms - +3.82ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
491.80ms - 502.01ms-unsure 🔍
-1% - +2%
-5.53ms - +8.17ms
unsure 🔍
-3% - +1%
-13.09ms - +5.63ms
tip-of-tree
tip-of-tree
491.01ms - 500.16msunsure 🔍
-2% - +1%
-8.17ms - +5.53ms
-unsure 🔍
-3% - +1%
-14.13ms - +4.04ms
previous-release
previous-release
492.78ms - 508.48msunsure 🔍
-1% - +3%
-5.63ms - +13.09ms
unsure 🔍
-1% - +3%
-4.04ms - +14.13ms
-

tachometer-reporter-action v2 for Benchmarks

Copy link
changeset-bot bot commented May 17, 2025

🦋 Changeset detected

Latest commit: 87f31d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@lit-labs/cli-mcp-server Minor
@lit-labs/cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@e111077 e111077 force-pushed the copilot-instructions branch from ef0d45c to 2213cb5 Compare May 17, 2025 02:04
@e111077 e111077 marked this pull request as ready for review May 17, 2025 02:05
@e111077 e111077 requested a review from kevinpschaaf as a code owner May 17, 2025 02:05
@e111077
Copy link
Contributor Author
e111077 commented May 17, 2025

I had issues writing tests for this. The CLI version of this package seems to be the only way we can test this with with CI. Issues are:

  1. Do we want to include network requests in our tests?
  2. Invoking it from within the directory with npx ran into version conflicts with a transitive commander dependency:
  • npx @modelcontextprotocol/inspector --cli --help # program.name(...).allowExcessArguments is not a function

Copy link
Contributor

The size of lit-html.js and lit-core.min.js are as expected.

@e111077 e111077 force-pushed the copilot-instructions branch from a81b2a8 to 42f84b1 Compare May 17, 2025 02:59
@e111077 e111077 force-pushed the copilot-instructions branch from 42f84b1 to 83e7f0b Compare May 17, 2025 04:13
Base automatically changed from copilot-instructions to main May 19, 2025 06:09
@e111077 e111077 requested a review from justinfagnani May 19, 2025 06:10
Copy link
Collaborator
@rictic rictic left a comment

Choose a reason for hiding this comment

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

Nice!

@e111077 e111077 changed the title [mcp-server] an initial implementation of a lit mcp server package feat(mcp): an initial implementation of a lit mcp server package Jun 5, 2025
@e111077 e111077 force-pushed the mcp-server branch 3 times, most recently from fd29310 to a312af9 Compare June 5, 2025 22:40
@e111077 e111077 changed the title feat(mcp): an initial implementation of a lit mcp server package feat(clit/mcp): an initial implementation of a lit mcp server package Jun 5, 2025
@e111077 e111077 requested a review from rictic June 5, 2025 22:46
@e111077 e111077 force-pushed the mcp-server branch 2 times, most recently from 4353115 to eadf6f8 Compare June 5, 2025 22:50
@e111077
Copy link
Contributor Author
e111077 commented Jun 5, 2025

@rictic PTAL: I've made some changes by adding this to the Lit CLI. I've updated the PR description

'The environment to run in, either "local" or "server". Server mode will ' +
'only expose MCP commands that are available on the server which are commands that do ' +
'not require local file access.',
typeLabel: '"local", "server"',
Copy link
Collaborator

Choose a reason for hiding this comment

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

What local filesystem tools are you thinking of?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what we were discussing previously:

  • Local, requires filesysten access like generating / finding CE manifests
  • Server, only requires network access to enable a RAG via MCP over HTTP (such as site search)

This implements a very basic mcp server that hooks into our algolia search for lit.dev. The key exposed is a rate-limited read-only key.
@e111077 e111077 6D40 changed the title feat(clit/mcp): an initial implementation of a lit mcp server package feat(cli/mcp): an initial implementation of a lit mcp server package Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0