Skip to content

Commit d8b6bf2

Browse files
committed
chore: #218 - adds ability to look up fields by name and retrieve by ID
1 parent 12992c4 commit d8b6bf2

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
TAG_SERVICES: 0.0.9
2323
TAG_EXTERNAL: 0.0.1
2424
TAG_UI: 0.0.31
25-
TAG_MCP: 0.0.6
25+
TAG_MCP: 0.0.7
2626

2727
steps:
2828
- name: Checkout code

objectified-mcp/server.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ async def get_schema_by_id(id: str) -> list[str]:
6969
print(f"[get_schema_by_id] id={id}")
7070
return result if len(result) > 0 else "{}"
7171

72+
@mcp.resource("fields://{name}/by_name")
73+
async def get_fields_by_name(name: str) -> list[str]:
74+
"""Retrieves a list of fields by ID and name based on the name specified"""
75+
conn = connect_to_postgres(DATABASE_URL)
76+
results = run_query(conn, "SELECT id, name FROM obj.field WHERE name LIKE %s", (f"%{name}%",))
77+
print(f"[get_fields_by_name]: search={name} results={len(results)}")
78+
return results if len(results) > 0 else []
79+
80+
@mcp.resource("fields://{id}/by_id")
81+
async def get_field_by_id(id: str) -> list[str]:
82+
"""Retrieves field information by ID"""
83+
conn = connect_to_postgres(DATABASE_URL)
84+
result = run_query(conn, "SELECT * FROM obj.field WHERE id=%s", (id,))
85+
print(f"[get_field_by_id] id={id}")
86+
return result if len(result) > 0 else "{}"
87+
7288
if __name__ == "__main__":
7389
print("""
7490
██████ ██████ ██ ███████ ██████ ████████ ██ ███████ ██ ███████ ██████

0 commit comments

Comments
 (0)