sldx-mcp 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sldx_mcp-1.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SLDX Tech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: sldx-mcp
3
+ Version: 1.2.0
4
+ Summary: MCP server for Brazilian B3 market data (stdio bridge to the SLDX API remote server)
5
+ Author-email: SLDX Tech <api@sldx.com.br>
6
+ License: MIT
7
+ Project-URL: Homepage, https://api.sldx.com.br/homepage/mcp
8
+ Keywords: mcp,b3,bovespa,fii,selic
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # sldx-mcp
15
+
16
+ MCP server for Brazilian market data (B3 stocks and FIIs, fundamentals, dividends, CVM funds, FX, Selic/IPCA).
17
+ It is a thin stdio bridge to the remote server `https://mcp.sldx.com.br/mcp`.
18
+
19
+ <!-- mcp-name: br.com.sldx/sldx -->
20
+
21
+ ## Use
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "sldx": {
27
+ "command": "uvx",
28
+ "args": ["sldx-mcp"],
29
+ "env": { "SLDX_TOKEN": "KID.SECRET" }
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ Without `SLDX_TOKEN` you can still try price and fundamentals of PETR4, VALE3, ITUB4 and MXRF11, plus Selic and IPCA.
36
+ Free token (no credit card): https://api.sldx.com.br/dev. Some tools need a paid plan.
37
+
38
+ MIT
@@ -0,0 +1,25 @@
1
+ # sldx-mcp
2
+
3
+ MCP server for Brazilian market data (B3 stocks and FIIs, fundamentals, dividends, CVM funds, FX, Selic/IPCA).
4
+ It is a thin stdio bridge to the remote server `https://mcp.sldx.com.br/mcp`.
5
+
6
+ <!-- mcp-name: br.com.sldx/sldx -->
7
+
8
+ ## Use
9
+
10
+ ```json
11
+ {
12
+ "mcpServers": {
13
+ "sldx": {
14
+ "command": "uvx",
15
+ "args": ["sldx-mcp"],
16
+ "env": { "SLDX_TOKEN": "KID.SECRET" }
17
+ }
18
+ }
19
+ }
20
+ ```
21
+
22
+ Without `SLDX_TOKEN` you can still try price and fundamentals of PETR4, VALE3, ITUB4 and MXRF11, plus Selic and IPCA.
23
+ Free token (no credit card): https://api.sldx.com.br/dev. Some tools need a paid plan.
24
+
25
+ MIT
@@ -0,0 +1,22 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sldx-mcp"
7
+ version = "1.2.0"
8
+ description = "MCP server for Brazilian B3 market data (stdio bridge to the SLDX API remote server)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "SLDX Tech", email = "api@sldx.com.br" }]
13
+ keywords = ["mcp", "b3", "bovespa", "fii", "selic"]
14
+
15
+ [project.urls]
16
+ Homepage = "https://api.sldx.com.br/homepage/mcp"
17
+
18
+ [project.scripts]
19
+ sldx-mcp = "sldx_mcp:main"
20
+
21
+ [tool.setuptools]
22
+ py-modules = ["sldx_mcp"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: sldx-mcp
3
+ Version: 1.2.0
4
+ Summary: MCP server for Brazilian B3 market data (stdio bridge to the SLDX API remote server)
5
+ Author-email: SLDX Tech <api@sldx.com.br>
6
+ License: MIT
7
+ Project-URL: Homepage, https://api.sldx.com.br/homepage/mcp
8
+ Keywords: mcp,b3,bovespa,fii,selic
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # sldx-mcp
15
+
16
+ MCP server for Brazilian market data (B3 stocks and FIIs, fundamentals, dividends, CVM funds, FX, Selic/IPCA).
17
+ It is a thin stdio bridge to the remote server `https://mcp.sldx.com.br/mcp`.
18
+
19
+ <!-- mcp-name: br.com.sldx/sldx -->
20
+
21
+ ## Use
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "sldx": {
27
+ "command": "uvx",
28
+ "args": ["sldx-mcp"],
29
+ "env": { "SLDX_TOKEN": "KID.SECRET" }
30
+ }
31
+ }
32
+ }
33
+ ```
34
+
35
+ Without `SLDX_TOKEN` you can still try price and fundamentals of PETR4, VALE3, ITUB4 and MXRF11, plus Selic and IPCA.
36
+ Free token (no credit card): https://api.sldx.com.br/dev. Some tools need a paid plan.
37
+
38
+ MIT
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ sldx_mcp.py
5
+ sldx_mcp.egg-info/PKG-INFO
6
+ sldx_mcp.egg-info/SOURCES.txt
7
+ sldx_mcp.egg-info/dependency_links.txt
8
+ sldx_mcp.egg-info/entry_points.txt
9
+ sldx_mcp.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sldx-mcp = sldx_mcp:main
@@ -0,0 +1 @@
1
+ sldx_mcp
@@ -0,0 +1,91 @@
1
+ """Ponte stdio -> HTTP para o servidor MCP remoto da SLDX. Sem SLDX_TOKEN, só o modo demo."""
2
+ import json
3
+ import os
4
+ import re
5
+ import sys
6
+ import urllib.error
7
+ import urllib.request
8
+
9
+ URL = os.environ.get("SLDX_MCP_URL", "https://mcp.sldx.com.br/mcp")
10
+ TOKEN = os.environ.get("SLDX_TOKEN", "").strip()
11
+ state = {"session": None, "version": None, "init": None}
12
+
13
+
14
+ def send(msg):
15
+ sys.stdout.buffer.write((json.dumps(msg, ensure_ascii=False) + "\n").encode("utf-8"))
16
+ sys.stdout.buffer.flush()
17
+
18
+
19
+ def post(msg, read_body=True):
20
+ headers = {
21
+ "Content-Type": "application/json",
22
+ "Accept": "application/json, text/event-stream",
23
+ "User-Agent": "sldx-mcp",
24
+ }
25
+ if TOKEN:
26
+ headers["Authorization"] = "Bearer " + TOKEN
27
+ if state["session"]:
28
+ headers["Mcp-Session-Id"] = state["session"]
29
+ if state["version"]:
30
+ headers["Mcp-Protocol-Version"] = state["version"]
31
+ req = urllib.request.Request(URL, json.dumps(msg).encode("utf-8"), headers, method="POST")
32
+ with urllib.request.urlopen(req, timeout=60) as res:
33
+ if not read_body or res.status == 202:
34
+ return res.headers, []
35
+ text = res.read().decode("utf-8")
36
+ if "text/event-stream" not in (res.headers.get("Content-Type") or ""):
37
+ data = json.loads(text) if text.strip() else []
38
+ return res.headers, data if isinstance(data, list) else [data]
39
+ out = []
40
+ for event in re.split(r"\r?\n\r?\n", text):
41
+ data = "\n".join(l[5:].strip() for l in event.splitlines() if l.startswith("data:"))
42
+ if data:
43
+ out.append(json.loads(data))
44
+ return res.headers, out
45
+
46
+
47
+ def initialize(msg):
48
+ state["session"] = state["version"] = None
49
+ headers, out = post(msg)
50
+ state["session"] = headers.get("Mcp-Session-Id")
51
+ for m in out:
52
+ state["version"] = (m.get("result") or {}).get("protocolVersion") or state["version"]
53
+ return out
54
+
55
+
56
+ def handle(msg):
57
+ is_request = msg.get("id") is not None and "method" in msg
58
+ try:
59
+ if msg.get("method") == "initialize":
60
+ state["init"] = msg
61
+ out = initialize(msg)
62
+ else:
63
+ try:
64
+ out = post(msg, is_request)[1]
65
+ except urllib.error.HTTPError as err:
66
+ if err.code != 404 or not state["init"]:
67
+ raise
68
+ initialize(state["init"]) # sessão expirou no servidor
69
+ out = post(msg, is_request)[1]
70
+ if is_request:
71
+ for m in out:
72
+ send(m)
73
+ except Exception as err:
74
+ if is_request:
75
+ send({"jsonrpc": "2.0", "id": msg["id"], "error": {"code": -32000, "message": "SLDX MCP: %s" % err}})
76
+
77
+
78
+ def main():
79
+ for raw in sys.stdin.buffer:
80
+ if not raw.strip():
81
+ continue
82
+ try:
83
+ msg = json.loads(raw.decode("utf-8"))
84
+ except ValueError:
85
+ send({"jsonrpc": "2.0", "id": None, "error": {"code": -32700, "message": "Parse error"}})
86
+ continue
87
+ handle(msg)
88
+
89
+
90
+ if __name__ == "__main__":
91
+ main()