find_project_by_name
Search for WeWork projects by name using similarity matching to find the most relevant project information based on specified thresholds.
Instructions
Tìm dự án theo tên với độ tương đồng
Args:
project_name: Tên dự án cần tìm
threshold: Ngưỡng tương đồng tối thiểu (default: 0.3)
Returns:
Thông tin dự án phù hợp nhất
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_name | Yes | ||
| threshold | No |
Implementation Reference
- wework_mcp_server.py:204-253 (handler)The handler function decorated with @mcp.tool(), which defines and registers the MCP tool. It fetches all projects, finds the best fuzzy match by name using WeWorkClient's find_best_project_match method, and returns the matching project or a list of available projects if no match above threshold.@mcp.tool() def find_project_by_name(project_name: str, threshold: float = 0.3) -> Dict[str, Any]: """ Tìm dự án theo tên với độ tương đồng Args: project_name: Tên dự án cần tìm threshold: Ngưỡng tương đồng tối thiểu (default: 0.3) Returns: Thông tin dự án phù hợp nhất """ try: if not wework_client: return {'error': 'WeWork client not initialized'} logger.info(f"Finding project by name: {project_name}") projects = wework_client.fetch_projects() if not projects: return { 'error': 'No projects available or failed to fetch projects', 'success': False } best_project, similarity_score = wework_client.find_best_project_match( project_name, projects, threshold ) if best_project: return { 'success': True, 'found': True, 'project': best_project, 'similarity_score': similarity_score, 'search_term': project_name } else: return { 'success': True, 'found': False, 'similarity_score': similarity_score, 'search_term': project_name, 'message': f'Không tìm thấy dự án phù hợp với "{project_name}" (ngưỡng: {threshold})', 'available_projects': [p.get('name', 'Unknown') for p in projects[:5]] # Show first 5 for reference } except Exception as e: logger.error(f"Error in find_project_by_name: {e}") return {'error': str(e), 'success': False}
- wework_mcp_server.py:204-204 (registration)The @mcp.tool() decorator registers the find_project_by_name function as an MCP tool.@mcp.tool()
- wework_mcp_server.py:205-205 (schema)Function signature defines input schema (project_name: str, threshold: float=0.3) and output as Dict[str, Any]. Docstring provides additional description.def find_project_by_name(project_name: str, threshold: float = 0.3) -> Dict[str, Any]: