Merge pull request #1584 from CREDO23/refactor-mcp-package-layout

[Refactor] MCP: flatten to mcp_server package (drop src layout)
This commit is contained in:
Thierry CH. 2026-07-07 20:32:00 +02:00 committed by GitHub
commit ac856ca6f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 31 additions and 31 deletions

View file

@ -33,4 +33,4 @@ ENV PYTHONUNBUFFERED=1 \
EXPOSE 8080 EXPOSE 8080
CMD ["python", "-m", "surfsense_mcp"] CMD ["python", "-m", "mcp_server"]

View file

@ -75,7 +75,7 @@ remote support. It uses [uv](https://github.com/astral-sh/uv):
```bash ```bash
cd surfsense_mcp cd surfsense_mcp
uv sync uv sync
uv run python -m surfsense_mcp.selfcheck # verify tools register correctly uv run python -m mcp_server.selfcheck # verify tools register correctly
``` ```
Then add it to your client. Cursor (`~/.cursor/mcp.json` or a project Then add it to your client. Cursor (`~/.cursor/mcp.json` or a project
@ -86,7 +86,7 @@ Then add it to your client. Cursor (`~/.cursor/mcp.json` or a project
"mcpServers": { "mcpServers": {
"surfsense": { "surfsense": {
"command": "uv", "command": "uv",
"args": ["run", "--directory", "/absolute/path/to/SurfSense/surfsense_mcp", "python", "-m", "surfsense_mcp"], "args": ["run", "--directory", "/absolute/path/to/SurfSense/surfsense_mcp", "python", "-m", "mcp_server"],
"env": { "env": {
"SURFSENSE_BASE_URL": "http://localhost:8000", "SURFSENSE_BASE_URL": "http://localhost:8000",
"SURFSENSE_API_KEY": "ss_pat_your_token_here" "SURFSENSE_API_KEY": "ss_pat_your_token_here"
@ -102,7 +102,7 @@ Claude Code:
claude mcp add surfsense \ claude mcp add surfsense \
-e SURFSENSE_BASE_URL=http://localhost:8000 \ -e SURFSENSE_BASE_URL=http://localhost:8000 \
-e SURFSENSE_API_KEY=ss_pat_your_token_here \ -e SURFSENSE_API_KEY=ss_pat_your_token_here \
-- uv run --directory /absolute/path/to/SurfSense/surfsense_mcp python -m surfsense_mcp -- uv run --directory /absolute/path/to/SurfSense/surfsense_mcp python -m mcp_server
``` ```
Claude Desktop: add the same `mcpServers` block as Cursor to Claude Desktop: add the same `mcpServers` block as Cursor to

View file

@ -13,7 +13,7 @@ dependencies = [
] ]
[project.scripts] [project.scripts]
surfsense-mcp = "surfsense_mcp.__main__:main" surfsense-mcp = "mcp_server.__main__:main"
[dependency-groups] [dependency-groups]
dev = ["pytest>=8.0"] dev = ["pytest>=8.0"]
@ -23,7 +23,7 @@ requires = ["hatchling"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel] [tool.hatch.build.targets.wheel]
packages = ["src/surfsense_mcp"] packages = ["mcp_server"]
[tool.ruff] [tool.ruff]
target-version = "py311" target-version = "py311"

View file

@ -4,7 +4,7 @@ from __future__ import annotations
from starlette.datastructures import Headers from starlette.datastructures import Headers
from surfsense_mcp.core.auth.headers import extract_api_key from mcp_server.core.auth.headers import extract_api_key
def _headers(**pairs: str) -> Headers: def _headers(**pairs: str) -> Headers:

View file

@ -4,7 +4,7 @@ from __future__ import annotations
import httpx import httpx
from surfsense_mcp.core.client import SurfSenseClient from mcp_server.core.client import SurfSenseClient
_REQUEST = httpx.Request("GET", "http://localhost:8000/api/v1/documents") _REQUEST = httpx.Request("GET", "http://localhost:8000/api/v1/documents")

View file

@ -6,7 +6,7 @@ import asyncio
import httpx import httpx
from surfsense_mcp.core.client import SurfSenseClient from mcp_server.core.client import SurfSenseClient
def _capture(client: SurfSenseClient) -> dict: def _capture(client: SurfSenseClient) -> dict:

View file

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from surfsense_mcp.features.knowledge_base.note_ingestion import build_note_document from mcp_server.features.knowledge_base.note_ingestion import build_note_document
def test_builds_extension_document_with_content(): def test_builds_extension_document_with_content():

View file

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
from surfsense_mcp.core.rendering import clip, compact_items, to_json from mcp_server.core.rendering import clip, compact_items, to_json
def test_clip_leaves_short_text_untouched(): def test_clip_leaves_short_text_untouched():

View file

@ -12,9 +12,9 @@ import asyncio
import httpx import httpx
import pytest import pytest
from surfsense_mcp.core.auth import identity from mcp_server.core.auth import identity
from surfsense_mcp.core.client import SurfSenseClient from mcp_server.core.client import SurfSenseClient
from surfsense_mcp.core.errors import ToolError from mcp_server.core.errors import ToolError
def _client_recording_auth(seen: dict, *, fallback: str | None) -> SurfSenseClient: def _client_recording_auth(seen: dict, *, fallback: str | None) -> SurfSenseClient:

View file

@ -6,9 +6,9 @@ import asyncio
import pytest import pytest
from surfsense_mcp.core.auth import identity from mcp_server.core.auth import identity
from surfsense_mcp.core.errors import ToolError from mcp_server.core.errors import ToolError
from surfsense_mcp.core.workspace_context import WorkspaceContext from mcp_server.core.workspace_context import WorkspaceContext
class FakeClient: class FakeClient:

View file

@ -56,7 +56,7 @@ Point the server at your backend with `SURFSENSE_BASE_URL`:
- **SurfSense Cloud**: `https://api.surfsense.com` - **SurfSense Cloud**: `https://api.surfsense.com`
- **Self-hosted**: wherever your backend runs, e.g. `http://localhost:8000` - **Self-hosted**: wherever your backend runs, e.g. `http://localhost:8000`
Every client below launches the same command — `uv run --directory <path-to>/surfsense_mcp python -m surfsense_mcp` — and passes `SURFSENSE_BASE_URL` and `SURFSENSE_API_KEY` as environment variables. Replace the placeholder paths and key with yours. Every client below launches the same command — `uv run --directory <path-to>/surfsense_mcp python -m mcp_server` — and passes `SURFSENSE_BASE_URL` and `SURFSENSE_API_KEY` as environment variables. Replace the placeholder paths and key with yours.
<Tabs items={['Claude Code', 'Codex', 'OpenCode', 'Cursor', 'Claude Desktop', 'VS Code', 'Windsurf', 'Gemini CLI']}> <Tabs items={['Claude Code', 'Codex', 'OpenCode', 'Cursor', 'Claude Desktop', 'VS Code', 'Windsurf', 'Gemini CLI']}>
<Tab value="Claude Code"> <Tab value="Claude Code">
@ -67,7 +67,7 @@ Run one command in a terminal:
claude mcp add surfsense \ claude mcp add surfsense \
-e SURFSENSE_BASE_URL=https://api.surfsense.com \ -e SURFSENSE_BASE_URL=https://api.surfsense.com \
-e SURFSENSE_API_KEY=ss_pat_your_key_here \ -e SURFSENSE_API_KEY=ss_pat_your_key_here \
-- uv run --directory /path/to/SurfSense/surfsense_mcp python -m surfsense_mcp -- uv run --directory /path/to/SurfSense/surfsense_mcp python -m mcp_server
``` ```
Start Claude Code and run `/mcp` — `surfsense` should be listed as connected. Add `--scope project` to share the server (without the key) via a checked-in `.mcp.json`. Start Claude Code and run `/mcp` — `surfsense` should be listed as connected. Add `--scope project` to share the server (without the key) via a checked-in `.mcp.json`.
@ -80,14 +80,14 @@ Add to `~/.codex/config.toml` (or a project's `.codex/config.toml`):
```toml ```toml
[mcp_servers.surfsense] [mcp_servers.surfsense]
command = "uv" command = "uv"
args = ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "surfsense_mcp"] args = ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "mcp_server"]
[mcp_servers.surfsense.env] [mcp_servers.surfsense.env]
SURFSENSE_BASE_URL = "https://api.surfsense.com" SURFSENSE_BASE_URL = "https://api.surfsense.com"
SURFSENSE_API_KEY = "ss_pat_your_key_here" SURFSENSE_API_KEY = "ss_pat_your_key_here"
``` ```
Or use the CLI: `codex mcp add surfsense -e SURFSENSE_API_KEY=... -- uv run --directory ... python -m surfsense_mcp`. Verify with `codex mcp list`. Or use the CLI: `codex mcp add surfsense -e SURFSENSE_API_KEY=... -- uv run --directory ... python -m mcp_server`. Verify with `codex mcp list`.
</Tab> </Tab>
<Tab value="OpenCode"> <Tab value="OpenCode">
@ -100,7 +100,7 @@ Add to `opencode.json` in your project root (or `~/.config/opencode/opencode.jso
"mcp": { "mcp": {
"surfsense": { "surfsense": {
"type": "local", "type": "local",
"command": ["uv", "run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "surfsense_mcp"], "command": ["uv", "run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "mcp_server"],
"enabled": true, "enabled": true,
"environment": { "environment": {
"SURFSENSE_BASE_URL": "https://api.surfsense.com", "SURFSENSE_BASE_URL": "https://api.surfsense.com",
@ -123,7 +123,7 @@ Add to `~/.cursor/mcp.json` (global — keeps the key out of your repo) or a pro
"mcpServers": { "mcpServers": {
"surfsense": { "surfsense": {
"command": "uv", "command": "uv",
"args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "surfsense_mcp"], "args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "mcp_server"],
"env": { "env": {
"SURFSENSE_BASE_URL": "https://api.surfsense.com", "SURFSENSE_BASE_URL": "https://api.surfsense.com",
"SURFSENSE_API_KEY": "ss_pat_your_key_here" "SURFSENSE_API_KEY": "ss_pat_your_key_here"
@ -145,7 +145,7 @@ Open **Settings → Developer → Edit Config** to reach `claude_desktop_config.
"mcpServers": { "mcpServers": {
"surfsense": { "surfsense": {
"command": "uv", "command": "uv",
"args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "surfsense_mcp"], "args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "mcp_server"],
"env": { "env": {
"SURFSENSE_BASE_URL": "https://api.surfsense.com", "SURFSENSE_BASE_URL": "https://api.surfsense.com",
"SURFSENSE_API_KEY": "ss_pat_your_key_here" "SURFSENSE_API_KEY": "ss_pat_your_key_here"
@ -168,7 +168,7 @@ Add to `.vscode/mcp.json` in your workspace (or run the **MCP: Add Server** comm
"surfsense": { "surfsense": {
"type": "stdio", "type": "stdio",
"command": "uv", "command": "uv",
"args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "surfsense_mcp"], "args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "mcp_server"],
"env": { "env": {
"SURFSENSE_BASE_URL": "https://api.surfsense.com", "SURFSENSE_BASE_URL": "https://api.surfsense.com",
"SURFSENSE_API_KEY": "ss_pat_your_key_here" "SURFSENSE_API_KEY": "ss_pat_your_key_here"
@ -190,7 +190,7 @@ Add the standard `mcpServers` block to `~/.codeium/windsurf/mcp_config.json` (or
"mcpServers": { "mcpServers": {
"surfsense": { "surfsense": {
"command": "uv", "command": "uv",
"args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "surfsense_mcp"], "args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "mcp_server"],
"env": { "env": {
"SURFSENSE_BASE_URL": "https://api.surfsense.com", "SURFSENSE_BASE_URL": "https://api.surfsense.com",
"SURFSENSE_API_KEY": "ss_pat_your_key_here" "SURFSENSE_API_KEY": "ss_pat_your_key_here"
@ -212,7 +212,7 @@ Add the standard `mcpServers` block to `~/.gemini/settings.json` (or `.gemini/se
"mcpServers": { "mcpServers": {
"surfsense": { "surfsense": {
"command": "uv", "command": "uv",
"args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "surfsense_mcp"], "args": ["run", "--directory", "/path/to/SurfSense/surfsense_mcp", "python", "-m", "mcp_server"],
"env": { "env": {
"SURFSENSE_BASE_URL": "https://api.surfsense.com", "SURFSENSE_BASE_URL": "https://api.surfsense.com",
"SURFSENSE_API_KEY": "ss_pat_your_key_here" "SURFSENSE_API_KEY": "ss_pat_your_key_here"
@ -257,7 +257,7 @@ For self-host (stdio), all settings are environment variables passed by the clie
- **401 errors** — the API key is wrong or expired; create a new one. - **401 errors** — the API key is wrong or expired; create a new one.
- **403 errors** — API access is disabled for the workspace; toggle **API key access** on under **API Playground → API Keys**. - **403 errors** — API access is disabled for the workspace; toggle **API key access** on under **API Playground → API Keys**.
- **"Could not reach SurfSense"** — the backend isn't running or `SURFSENSE_BASE_URL` is wrong. - **"Could not reach SurfSense"** — the backend isn't running or `SURFSENSE_BASE_URL` is wrong.
- **Server won't start** — run `uv run python -m surfsense_mcp.selfcheck` inside `surfsense_mcp`; it verifies all 18 tools register without needing a backend. - **Server won't start** — run `uv run python -m mcp_server.selfcheck` inside `surfsense_mcp`; it verifies all 18 tools register without needing a backend.
## Tools reference ## Tools reference

View file

@ -52,7 +52,7 @@ function bearer(apiKey: string): string {
} }
function serverArgs(serverDir: string): string[] { function serverArgs(serverDir: string): string[] {
return ["run", "--directory", serverDir, "python", "-m", "surfsense_mcp"]; return ["run", "--directory", serverDir, "python", "-m", "mcp_server"];
} }
/** The `mcpServers` remote shape shared by Cursor, Windsurf, and Gemini CLI. */ /** The `mcpServers` remote shape shared by Cursor, Windsurf, and Gemini CLI. */
@ -110,7 +110,7 @@ export const MCP_CLIENTS: McpClient[] = [
"claude mcp add surfsense \\", "claude mcp add surfsense \\",
` -e SURFSENSE_BASE_URL=${baseUrl} \\`, ` -e SURFSENSE_BASE_URL=${baseUrl} \\`,
` -e SURFSENSE_API_KEY=${apiKey} \\`, ` -e SURFSENSE_API_KEY=${apiKey} \\`,
` -- uv run --directory ${serverDir} python -m surfsense_mcp`, ` -- uv run --directory ${serverDir} python -m mcp_server`,
].join("\n"), ].join("\n"),
}, },
}, },
@ -139,7 +139,7 @@ export const MCP_CLIENTS: McpClient[] = [
configFile: "~/.codex/config.toml", configFile: "~/.codex/config.toml",
language: "toml", language: "toml",
steps: [ steps: [
"Add this to ~/.codex/config.toml (or run `codex mcp add surfsense -- uv run --directory <dir> python -m surfsense_mcp`).", "Add this to ~/.codex/config.toml (or run `codex mcp add surfsense -- uv run --directory <dir> python -m mcp_server`).",
"Restart Codex; `codex mcp list` should show surfsense.", "Restart Codex; `codex mcp list` should show surfsense.",
], ],
build: ({ baseUrl, apiKey, serverDir }) => build: ({ baseUrl, apiKey, serverDir }) =>