elm-mcp 0.1.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.
- elm_mcp-0.1.0/.github/workflows/pypi.yml +26 -0
- elm_mcp-0.1.0/PKG-INFO +47 -0
- elm_mcp-0.1.0/README.md +28 -0
- elm_mcp-0.1.0/pyproject.toml +36 -0
- elm_mcp-0.1.0/src/elm_mcp/__init__.py +0 -0
- elm_mcp-0.1.0/src/elm_mcp/server.py +201 -0
- elm_mcp-0.1.0/uv.lock +1430 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
id-token: write
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
|
|
19
|
+
- name: Install build tools
|
|
20
|
+
run: pip install build
|
|
21
|
+
|
|
22
|
+
- name: Build package
|
|
23
|
+
run: python -m build
|
|
24
|
+
|
|
25
|
+
- name: Publish to PyPI
|
|
26
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
elm_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: elm-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP Server for IBM ELM (Engineering Lifecycle Management)
|
|
5
|
+
Project-URL: Homepage, https://github.com/filhocf/elm-mcp
|
|
6
|
+
Project-URL: Source, https://github.com/filhocf/elm-mcp
|
|
7
|
+
Author-email: Claudio Ferreira Filho <filhocf@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: alm,elm,ibm,jazz,mcp,oslc
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Requires-Python: >=3.11
|
|
16
|
+
Requires-Dist: elmclient>=0.37.0
|
|
17
|
+
Requires-Dist: mcp[cli]>=1.9.0
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# elm-mcp
|
|
21
|
+
|
|
22
|
+
MCP Server for IBM ELM (Engineering Lifecycle Management).
|
|
23
|
+
|
|
24
|
+
Exposes IBM ELM/Jazz work items, requirements, and projects as MCP tools.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uvx elm-mcp
|
|
30
|
+
# or
|
|
31
|
+
pip install elm-mcp
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
Create `~/.elm_creds.json`:
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"username": "your.user",
|
|
40
|
+
"password": "your.password"
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
- IBM ELM/Jazz server accessible (e.g., `https://alm.dataprev.gov.br`)
|
|
47
|
+
- Valid credentials with API access
|
elm_mcp-0.1.0/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# elm-mcp
|
|
2
|
+
|
|
3
|
+
MCP Server for IBM ELM (Engineering Lifecycle Management).
|
|
4
|
+
|
|
5
|
+
Exposes IBM ELM/Jazz work items, requirements, and projects as MCP tools.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uvx elm-mcp
|
|
11
|
+
# or
|
|
12
|
+
pip install elm-mcp
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Configuration
|
|
16
|
+
|
|
17
|
+
Create `~/.elm_creds.json`:
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"username": "your.user",
|
|
21
|
+
"password": "your.password"
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Requirements
|
|
26
|
+
|
|
27
|
+
- IBM ELM/Jazz server accessible (e.g., `https://alm.dataprev.gov.br`)
|
|
28
|
+
- Valid credentials with API access
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "elm-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP Server for IBM ELM (Engineering Lifecycle Management)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Claudio Ferreira Filho", email = "filhocf@gmail.com" }
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.11"
|
|
15
|
+
keywords = ["mcp", "elm", "ibm", "alm", "jazz", "oslc"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
]
|
|
23
|
+
dependencies = [
|
|
24
|
+
"mcp[cli]>=1.9.0",
|
|
25
|
+
"elmclient>=0.37.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
elm-mcp = "elm_mcp.server:main"
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/filhocf/elm-mcp"
|
|
33
|
+
Source = "https://github.com/filhocf/elm-mcp"
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/elm_mcp"]
|
|
File without changes
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MCP Server para IBM ELM - ALM Dataprev
|
|
3
|
+
Expõe work items, requisitos e projetos do ELM como tools MCP.
|
|
4
|
+
"""
|
|
5
|
+
import os
|
|
6
|
+
import json
|
|
7
|
+
import base64
|
|
8
|
+
from mcp.server.fastmcp import FastMCP
|
|
9
|
+
|
|
10
|
+
import elmclient.server as elmserver
|
|
11
|
+
import elmclient.rdfxml as rdfxml
|
|
12
|
+
|
|
13
|
+
mcp = FastMCP("elm", instructions="IBM ELM (ALM Dataprev)")
|
|
14
|
+
|
|
15
|
+
JAZZ_HOST = "https://alm.dataprev.gov.br"
|
|
16
|
+
CRED_FILE = os.path.expanduser("~/.elm_creds.json")
|
|
17
|
+
|
|
18
|
+
PREFIXES = {
|
|
19
|
+
"http://purl.org/dc/terms/": "dcterms",
|
|
20
|
+
"http://open-services.net/ns/cm#": "oslc_cm",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _safe_str(val) -> str:
|
|
25
|
+
"""Converte valor para string UTF-8 segura, tratando bytes Latin1/CP1252."""
|
|
26
|
+
if isinstance(val, bytes):
|
|
27
|
+
try:
|
|
28
|
+
return val.decode('utf-8')
|
|
29
|
+
except UnicodeDecodeError:
|
|
30
|
+
return val.decode('cp1252', errors='replace')
|
|
31
|
+
if isinstance(val, str):
|
|
32
|
+
try:
|
|
33
|
+
val.encode('utf-8')
|
|
34
|
+
return val
|
|
35
|
+
except UnicodeEncodeError:
|
|
36
|
+
return val.encode('cp1252', errors='replace').decode('utf-8', errors='replace')
|
|
37
|
+
return str(val)
|
|
38
|
+
|
|
39
|
+
# --- Conexão lazy (singleton) ---
|
|
40
|
+
_connections: dict = {}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _load_creds() -> tuple[str, str]:
|
|
44
|
+
if not os.path.exists(CRED_FILE):
|
|
45
|
+
raise RuntimeError(
|
|
46
|
+
f"Credenciais não encontradas em {CRED_FILE}. "
|
|
47
|
+
"Rode primeiro: python test_connection.py"
|
|
48
|
+
)
|
|
49
|
+
with open(CRED_FILE) as f:
|
|
50
|
+
data = json.load(f)
|
|
51
|
+
return data["username"], base64.b64decode(data["password"]).decode()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _get_server():
|
|
55
|
+
if "server" not in _connections:
|
|
56
|
+
username, password = _load_creds()
|
|
57
|
+
_connections["server"] = elmserver.JazzTeamServer(
|
|
58
|
+
JAZZ_HOST, username, password,
|
|
59
|
+
verifysslcerts=True,
|
|
60
|
+
jtsappstring="jts",
|
|
61
|
+
appstring="ccm",
|
|
62
|
+
cachingcontrol=0,
|
|
63
|
+
)
|
|
64
|
+
return _connections["server"]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _get_app(domain: str = "ccm"):
|
|
68
|
+
key = f"app_{domain}"
|
|
69
|
+
if key not in _connections:
|
|
70
|
+
server = _get_server()
|
|
71
|
+
_connections[key] = server.find_app(domain, ok_to_create=True)
|
|
72
|
+
return _connections[key]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# --- Tools ---
|
|
76
|
+
|
|
77
|
+
@mcp.tool()
|
|
78
|
+
def list_projects(domain: str = "ccm") -> str:
|
|
79
|
+
"""Lista projetos acessíveis no ELM.
|
|
80
|
+
domain: 'ccm' (EWM/work items), 'rm' (DOORS Next/requisitos), 'qm' (ETM/testes)
|
|
81
|
+
"""
|
|
82
|
+
app = _get_app(domain)
|
|
83
|
+
app._load_projects()
|
|
84
|
+
projects = []
|
|
85
|
+
for uri, info in app._projects.items():
|
|
86
|
+
if isinstance(info, dict):
|
|
87
|
+
projects.append({"name": _safe_str(info.get("name", "?")), "uri": _safe_str(uri)})
|
|
88
|
+
return json.dumps(projects, ensure_ascii=False, indent=2)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@mcp.tool()
|
|
92
|
+
def list_workitems(
|
|
93
|
+
project_name: str = "MEU IMOVEL RURAL (MIR)",
|
|
94
|
+
pagesize: int = 30,
|
|
95
|
+
query: str = "",
|
|
96
|
+
) -> str:
|
|
97
|
+
"""Lista work items de um projeto EWM.
|
|
98
|
+
project_name: nome do projeto
|
|
99
|
+
pagesize: quantidade de resultados (default 30)
|
|
100
|
+
query: filtro OSLC opcional (ex: dcterms:type="task")
|
|
101
|
+
"""
|
|
102
|
+
app = _get_app("ccm")
|
|
103
|
+
project = app.find_project(project_name)
|
|
104
|
+
if not project:
|
|
105
|
+
return json.dumps({"error": f"Projeto '{project_name}' não encontrado"})
|
|
106
|
+
|
|
107
|
+
services_xml = project.get_services_xml()
|
|
108
|
+
qcaps = rdfxml.xml_find_elements(
|
|
109
|
+
services_xml,
|
|
110
|
+
".//{http://open-services.net/ns/core#}QueryCapability"
|
|
111
|
+
)
|
|
112
|
+
query_base = None
|
|
113
|
+
for qc in qcaps:
|
|
114
|
+
qb = rdfxml.xmlrdf_get_resource_uri(qc, "oslc:queryBase")
|
|
115
|
+
if qb:
|
|
116
|
+
query_base = qb
|
|
117
|
+
break
|
|
118
|
+
|
|
119
|
+
if not query_base:
|
|
120
|
+
return json.dumps({"error": "Query capability não encontrada"})
|
|
121
|
+
|
|
122
|
+
kwargs = dict(
|
|
123
|
+
select=["dcterms:identifier", "dcterms:title"],
|
|
124
|
+
orderbys=["-dcterms:modified"],
|
|
125
|
+
prefixes=PREFIXES,
|
|
126
|
+
pagesize=pagesize,
|
|
127
|
+
)
|
|
128
|
+
if query:
|
|
129
|
+
kwargs["whereterms"] = query
|
|
130
|
+
|
|
131
|
+
results = project.execute_oslc_query(query_base, **kwargs)
|
|
132
|
+
|
|
133
|
+
items = []
|
|
134
|
+
for uri, attrs in results.items():
|
|
135
|
+
items.append({
|
|
136
|
+
"id": _safe_str(attrs.get("dcterms:identifier", "?")),
|
|
137
|
+
"title": _safe_str(attrs.get("dcterms:title", "?")),
|
|
138
|
+
"uri": _safe_str(uri),
|
|
139
|
+
})
|
|
140
|
+
return json.dumps(items, ensure_ascii=False, indent=2)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@mcp.tool()
|
|
144
|
+
def get_workitem(
|
|
145
|
+
project_name: str = "MEU IMOVEL RURAL (MIR)",
|
|
146
|
+
workitem_id: str = "",
|
|
147
|
+
) -> str:
|
|
148
|
+
"""Busca detalhes de um work item específico pelo ID.
|
|
149
|
+
project_name: nome do projeto
|
|
150
|
+
workitem_id: identificador do work item (ex: '615472')
|
|
151
|
+
"""
|
|
152
|
+
app = _get_app("ccm")
|
|
153
|
+
project = app.find_project(project_name)
|
|
154
|
+
if not project:
|
|
155
|
+
return json.dumps({"error": f"Projeto '{project_name}' não encontrado"})
|
|
156
|
+
|
|
157
|
+
services_xml = project.get_services_xml()
|
|
158
|
+
qcaps = rdfxml.xml_find_elements(
|
|
159
|
+
services_xml,
|
|
160
|
+
".//{http://open-services.net/ns/core#}QueryCapability"
|
|
161
|
+
)
|
|
162
|
+
query_base = None
|
|
163
|
+
for qc in qcaps:
|
|
164
|
+
qb = rdfxml.xmlrdf_get_resource_uri(qc, "oslc:queryBase")
|
|
165
|
+
if qb:
|
|
166
|
+
query_base = qb
|
|
167
|
+
break
|
|
168
|
+
|
|
169
|
+
if not query_base:
|
|
170
|
+
return json.dumps({"error": "Query capability não encontrada"})
|
|
171
|
+
|
|
172
|
+
results = project.execute_oslc_query(
|
|
173
|
+
query_base,
|
|
174
|
+
whereterms=[["dcterms:identifier", "=", f'"{workitem_id}"']],
|
|
175
|
+
select=["*"],
|
|
176
|
+
prefixes=PREFIXES,
|
|
177
|
+
pagesize=1,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
if not results:
|
|
181
|
+
return json.dumps({"error": f"Work item {workitem_id} não encontrado"})
|
|
182
|
+
|
|
183
|
+
uri, attrs = next(iter(results.items()))
|
|
184
|
+
# Converter valores para strings UTF-8 seguras
|
|
185
|
+
clean = {"uri": _safe_str(uri)}
|
|
186
|
+
for k, v in attrs.items():
|
|
187
|
+
clean[_safe_str(k)] = _safe_str(v)
|
|
188
|
+
return json.dumps(clean, ensure_ascii=False, indent=2)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
if __name__ == "__main__":
|
|
192
|
+
mcp.run()
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def main():
|
|
196
|
+
"""Entry point for elm-mcp CLI."""
|
|
197
|
+
mcp.run()
|
|
198
|
+
|
|
199
|
+
if __name__ == "__main__":
|
|
200
|
+
main()
|
|
201
|
+
|