| name | molecular-similarity-search |
| description | Search for similar molecules using Tanimoto similarity with Morgan fingerprints to identify structurally related compounds. |
| license | MIT license |
| metadata | {"skill-author":"PJLab"} |
Molecular Similarity Search
Usage
1. MCP Server Definition
import asyncio
import json
from contextlib import AsyncExitStack
from mcp.client.streamable_http import streamablehttp_client
from mcp import ClientSession
class DrugSDAClient:
"""DrugSDA-Tool MCP Client"""
def __init__(self, server_url: str, api_key: str):
self.server_url = server_url
self.api_key = api_key
self.session = None
():
()
:
.transport = streamablehttp_client(
url=.server_url,
headers={: .api_key}
)
._stack = AsyncExitStack()
._stack.__aenter__()
.read, .write, .get_session_id = ._stack.enter_async_context(.transport)
.session_ctx = ClientSession(.read, .write)
.session = ._stack.enter_async_context(.session_ctx)
.session.initialize()
session_id = .get_session_id()
()
Exception e:
()
():
:
(, ):
._stack.aclose()
()
Exception e:
()
():
:
(result, ) result.content:
content = result.content[]
(content, ):
json.loads(content.text)
(result)
Exception e:
{: , : (result)}