Skip to content

Commit c4b39b8

Browse files
lurenssclaude
andcommitted
feat: migrate to Smithery Python deployment model
- Remove Dockerfile (Smithery handles containerization automatically) - Update smithery.yaml to use Python runtime configuration - Add smithery dependency and [tool.smithery] configuration in pyproject.toml - Add @smithery.server() decorator to create_server function - Add config schema for scrapegraphApiKey configuration - Clean up .gitignore (remove node_modules reference) This migration aligns the project with Smithery's Python deployment requirements, fixing the prepareBuildError during deployment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6bf2e15 commit c4b39b8

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,5 @@ env/
3737
.env
3838
.env.local
3939

40-
# Node-generated files (if any)
41-
node_modules/
42-
4340
# Logs
4441
*.log

Dockerfile

Lines changed: 0 additions & 20 deletions
This file was deleted.

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ requires-python = ">=3.10"
1111
dependencies = [
1212
"fastmcp>=2.0.0",
1313
"httpx>=0.24.0",
14+
"smithery>=0.1.0",
1415
]
1516
classifiers = [
1617
"Development Status :: 4 - Beta",
@@ -54,4 +55,7 @@ python_version = "3.12"
5455
warn_return_any = true
5556
warn_unused_configs = true
5657
disallow_untyped_defs = true
57-
disallow_incomplete_defs = true
58+
disallow_incomplete_defs = true
59+
60+
[tool.smithery]
61+
server = "scrapegraph_mcp.server:create_server"

smithery.yaml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,2 @@
11
# Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
2-
3-
startCommand:
4-
type: stdio
5-
configSchema:
6-
# JSON Schema defining the configuration options for the MCP.
7-
type: object
8-
required:
9-
- scrapegraphApiKey
10-
properties:
11-
scrapegraphApiKey:
12-
type: string
13-
description: Your Scrapegraph API key
14-
commandFunction:
15-
# A JS function that produces the CLI command based on the given config to start the MCP on stdio.
16-
|-
17-
(config) => ({
18-
command: 'scrapegraph-mcp',
19-
args: [],
20-
env: {
21-
SGAI_API_KEY: config.scrapegraphApiKey
22-
}
23-
})
24-
exampleConfig:
25-
scrapegraphApiKey: sgai-1234567890
2+
runtime: "python"

src/scrapegraph_mcp/server.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import httpx
1717
from fastmcp import FastMCP
18+
from smithery.decorators import smithery
1819

1920

2021
class ScapeGraphClient:
@@ -556,6 +557,47 @@ def agentic_scrapper(
556557
return {"error": str(val_err)}
557558

558559

560+
# Config schema for Smithery
561+
CONFIG_SCHEMA = {
562+
"type": "object",
563+
"required": ["scrapegraphApiKey"],
564+
"properties": {
565+
"scrapegraphApiKey": {
566+
"type": "string",
567+
"description": "Your Scrapegraph API key"
568+
}
569+
}
570+
}
571+
572+
573+
@smithery.server(config_schema=CONFIG_SCHEMA)
574+
def create_server(config: Optional[Dict[str, Any]] = None) -> FastMCP:
575+
"""
576+
Create and return the FastMCP server instance for Smithery deployment.
577+
578+
Args:
579+
config: Configuration dictionary with optional keys:
580+
- scrapegraphApiKey: API key for ScapeGraph API
581+
582+
Returns:
583+
Configured FastMCP server instance
584+
"""
585+
global scrapegraph_client
586+
587+
# Get API key from config or environment
588+
api_key = None
589+
if config and "scrapegraphApiKey" in config:
590+
api_key = config["scrapegraphApiKey"]
591+
else:
592+
api_key = os.environ.get("SGAI_API_KEY")
593+
594+
# Initialize client if API key is available
595+
if api_key:
596+
scrapegraph_client = ScapeGraphClient(api_key)
597+
598+
return mcp
599+
600+
559601
def main() -> None:
560602
"""Run the ScapeGraph MCP server."""
561603
print("Starting ScapeGraph MCP server!")
@@ -564,4 +606,4 @@ def main() -> None:
564606

565607

566608
if __name__ == "__main__":
567-
main()
609+
main()

0 commit comments

Comments
 (0)