Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ uvx semgrep-mcp # see --help for more options
Or, run as a [Docker container](https://ghcr.io/semgrep/mcp):

```bash
docker run -i --rm ghcr.io/semgrep/mcp -t stdio
docker run -i --rm ghcr.io/semgrep/mcp -t stdio
```

### Cursor
Expand Down Expand Up @@ -473,7 +473,7 @@ async def main():
{
"code_files": [
{
"filename": "hello_world.py",
"path": "hello_world.py",
"content": "def hello(): print('Hello, World!')",
}
]
Expand Down
2 changes: 1 addition & 1 deletion examples/sse_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def main():
{
"code_files": [
{
"filename": "hello_world.py",
"path": "hello_world.py",
"content": "def hello(): print('Hello, World!')",
}
]
Expand Down
2 changes: 1 addition & 1 deletion examples/streamable_http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def main():
{
"code_files": [
{
"filename": "hello_world.py",
"path": "hello_world.py",
"content": "def hello(): print('Hello, World!')",
}
]
Expand Down
11 changes: 6 additions & 5 deletions src/semgrep_mcp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
from pydantic import BaseModel, Field, HttpUrl


class LocalCodeFile(BaseModel):
path: str = Field(description="Absolute path to be scanned locally by Semgrep.")


class CodeFile(BaseModel):
filename: str = Field(description="Relative path to the code file")
# This "path" is mostly for bookkeeping purposes.
# Depending on whether the server is hosted or not, this path might
# not actually exist on the filesystem.
path: str = Field(description="Path of the code file")
# The `content` field will be filled in either by the LLM (in the remote scanning case)
# or gleaned from the filesystem (in the local scanning case).
content: str = Field(description="Content of the code file")


Expand Down
4 changes: 3 additions & 1 deletion src/semgrep_mcp/semgrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ async def run_semgrep_via_rpc(context: SemgrepContext, data: list[CodeFile]) ->
List of CliMatch objects
"""

files_json = [{"file": data.filename, "content": data.content} for data in data]
# TODO: to be honest it's silly for us to wire the contents of the files over RPC
# if they exist on the local filesystem, we could just pass the paths
files_json = [{"file": data.path, "content": data.content} for data in data]

# ATD serialized value
resp = await context.send_request("scanFiles", files=files_json)
Expand Down
Loading
Loading