Run mattermost-search MCP over shared HTTP and fix FTS hangs.
Avoid per-agent stdio contention on the sqlite index, sort FTS by rank with created tie-break, and add mm_search_tag for dated #plan/#report substring search. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+23
-13
@@ -160,7 +160,9 @@ def refresh_user_directory(
|
||||
config_path: Optional[str] = None,
|
||||
from_api: bool = False,
|
||||
) -> Dict[str, Any]:
|
||||
conn = sqlite3.connect(db_path)
|
||||
from mm_search import open_db
|
||||
|
||||
conn = open_db(db_path, readonly=False, timeout=30.0)
|
||||
ensure_users_schema(conn)
|
||||
sources: List[str] = []
|
||||
profiles: List[Dict[str, str]] = []
|
||||
@@ -256,12 +258,16 @@ def search_users(
|
||||
if not ref:
|
||||
return []
|
||||
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn.row_factory = sqlite3.Row
|
||||
ensure_users_schema(conn)
|
||||
rows = conn.execute(
|
||||
"SELECT username, first_name, last_name, nickname, full_name FROM users"
|
||||
).fetchall()
|
||||
from mm_search import open_db
|
||||
|
||||
conn = open_db(db_path, readonly=True)
|
||||
try:
|
||||
rows = conn.execute(
|
||||
"SELECT username, first_name, last_name, nickname, full_name FROM users"
|
||||
).fetchall()
|
||||
except sqlite3.Error:
|
||||
conn.close()
|
||||
return []
|
||||
conn.close()
|
||||
|
||||
matched = [
|
||||
@@ -288,12 +294,16 @@ def resolve_user(db_path: str, ref: str) -> Dict[str, Any]:
|
||||
if not ref:
|
||||
raise ValueError("ref must be non-empty")
|
||||
|
||||
conn = sqlite3.connect(db_path)
|
||||
conn.row_factory = sqlite3.Row
|
||||
ensure_users_schema(conn)
|
||||
rows = conn.execute(
|
||||
"SELECT username, first_name, last_name, nickname, full_name FROM users"
|
||||
).fetchall()
|
||||
from mm_search import open_db
|
||||
|
||||
conn = open_db(db_path, readonly=True)
|
||||
try:
|
||||
rows = conn.execute(
|
||||
"SELECT username, first_name, last_name, nickname, full_name FROM users"
|
||||
).fetchall()
|
||||
except sqlite3.Error:
|
||||
conn.close()
|
||||
return {"found": False, "ref": ref, "matches": [], "error": "users table missing; run mm_user_directory_refresh"}
|
||||
conn.close()
|
||||
|
||||
best = [row for row in rows if _match_score(ref, row) > 0]
|
||||
|
||||
Reference in New Issue
Block a user