claude-self-reflect 2.5.8 → 2.5.10
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.
- package/mcp-server/pyproject.toml +1 -1
- package/mcp-server/src/server.py +40 -146
- package/package.json +1 -1
package/mcp-server/src/server.py
CHANGED
|
@@ -192,10 +192,13 @@ async def reflect_on_past(
|
|
|
192
192
|
|
|
193
193
|
# Determine project scope
|
|
194
194
|
target_project = project
|
|
195
|
+
|
|
196
|
+
# Always get the working directory for logging purposes
|
|
197
|
+
cwd = os.environ.get('MCP_CLIENT_CWD', os.getcwd())
|
|
198
|
+
|
|
195
199
|
if project is None:
|
|
196
200
|
# Use MCP_CLIENT_CWD environment variable set by run-mcp.sh
|
|
197
201
|
# This contains the actual working directory where Claude Code is running
|
|
198
|
-
cwd = os.environ.get('MCP_CLIENT_CWD', os.getcwd())
|
|
199
202
|
|
|
200
203
|
# Extract project name from path (e.g., /Users/.../projects/project-name)
|
|
201
204
|
path_parts = Path(cwd).parts
|
|
@@ -744,48 +747,17 @@ async def quick_search(
|
|
|
744
747
|
project: Optional[str] = Field(default=None, description="Search specific project only. If not provided, searches current project based on working directory. Use 'all' to search across all projects.")
|
|
745
748
|
) -> str:
|
|
746
749
|
"""Quick search that returns only the count and top result for fast overview."""
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
)
|
|
759
|
-
|
|
760
|
-
# Parse and reformat for quick overview
|
|
761
|
-
import re
|
|
762
|
-
|
|
763
|
-
# Extract count from metadata
|
|
764
|
-
count_match = re.search(r'<tc>(\d+)</tc>', result)
|
|
765
|
-
total_count = count_match.group(1) if count_match else "0"
|
|
766
|
-
|
|
767
|
-
# Extract top result
|
|
768
|
-
score_match = re.search(r'<s>([\d.]+)</s>', result)
|
|
769
|
-
project_match = re.search(r'<p>([^<]+)</p>', result)
|
|
770
|
-
title_match = re.search(r'<t>([^<]+)</t>', result)
|
|
771
|
-
|
|
772
|
-
if score_match and project_match and title_match:
|
|
773
|
-
return f"""<quick_search>
|
|
774
|
-
<total_matches>{total_count}</total_matches>
|
|
775
|
-
<top_result>
|
|
776
|
-
<score>{score_match.group(1)}</score>
|
|
777
|
-
<project>{project_match.group(1)}</project>
|
|
778
|
-
<title>{title_match.group(1)}</title>
|
|
779
|
-
</top_result>
|
|
780
|
-
</quick_search>"""
|
|
781
|
-
else:
|
|
782
|
-
return f"""<quick_search>
|
|
783
|
-
<total_matches>{total_count}</total_matches>
|
|
784
|
-
<message>No relevant matches found</message>
|
|
785
|
-
</quick_search>"""
|
|
786
|
-
except Exception as e:
|
|
787
|
-
await ctx.error(f"Quick search failed: {str(e)}")
|
|
788
|
-
return f"<quick_search><error>{str(e)}</error></quick_search>"
|
|
750
|
+
# MCP architectural limitation: MCP tools cannot call other MCP tools
|
|
751
|
+
return """<error>
|
|
752
|
+
MCP Architectural Limitation: This tool cannot directly call other MCP tools.
|
|
753
|
+
|
|
754
|
+
To perform a quick search, please:
|
|
755
|
+
1. Call reflect_on_past directly with limit=1 and brief=True
|
|
756
|
+
2. Or use the reflection-specialist agent for quick searches
|
|
757
|
+
|
|
758
|
+
This limitation exists because MCP tools can only be orchestrated by the client (Claude),
|
|
759
|
+
not by other tools within the MCP server.
|
|
760
|
+
</error>"""
|
|
789
761
|
|
|
790
762
|
|
|
791
763
|
@mcp.tool()
|
|
@@ -795,68 +767,20 @@ async def search_summary(
|
|
|
795
767
|
project: Optional[str] = Field(default=None, description="Search specific project only. If not provided, searches current project based on working directory. Use 'all' to search across all projects.")
|
|
796
768
|
) -> str:
|
|
797
769
|
"""Get aggregated insights from search results without individual result details."""
|
|
798
|
-
#
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
from collections import Counter
|
|
813
|
-
|
|
814
|
-
# Extract all projects
|
|
815
|
-
projects = re.findall(r'<p>([^<]+)</p>', result)
|
|
816
|
-
project_counts = Counter(projects)
|
|
817
|
-
|
|
818
|
-
# Extract scores for statistics
|
|
819
|
-
scores = [float(s) for s in re.findall(r'<s>([\d.]+)</s>', result)]
|
|
820
|
-
avg_score = sum(scores) / len(scores) if scores else 0
|
|
821
|
-
|
|
822
|
-
# Extract themes from titles and excerpts
|
|
823
|
-
titles = re.findall(r'<t>([^<]+)</t>', result)
|
|
824
|
-
excerpts = re.findall(r'<e>([^<]+)</e>', result)
|
|
825
|
-
|
|
826
|
-
# Extract metadata
|
|
827
|
-
count_match = re.search(r'<tc>(\d+)</tc>', result)
|
|
828
|
-
total_count = count_match.group(1) if count_match else "0"
|
|
829
|
-
|
|
830
|
-
# Generate summary
|
|
831
|
-
summary = f"""<search_summary>
|
|
832
|
-
<total_matches>{total_count}</total_matches>
|
|
833
|
-
<searched_projects>{len(project_counts)}</searched_projects>
|
|
834
|
-
<average_relevance>{avg_score:.2f}</average_relevance>
|
|
835
|
-
<project_distribution>"""
|
|
836
|
-
|
|
837
|
-
for proj, count in project_counts.most_common(3):
|
|
838
|
-
summary += f"\n <project name='{proj}' matches='{count}'/>"
|
|
839
|
-
|
|
840
|
-
summary += f"""
|
|
841
|
-
</project_distribution>
|
|
842
|
-
<common_themes>"""
|
|
843
|
-
|
|
844
|
-
# Simple theme extraction from titles
|
|
845
|
-
theme_words = []
|
|
846
|
-
for title in titles[:5]: # Top 5 results
|
|
847
|
-
words = [w.lower() for w in title.split() if len(w) > 4]
|
|
848
|
-
theme_words.extend(words)
|
|
849
|
-
|
|
850
|
-
theme_counts = Counter(theme_words)
|
|
851
|
-
for theme, count in theme_counts.most_common(5):
|
|
852
|
-
if count > 1: # Only show repeated themes
|
|
853
|
-
summary += f"\n <theme>{theme}</theme>"
|
|
854
|
-
|
|
855
|
-
summary += """
|
|
856
|
-
</common_themes>
|
|
857
|
-
</search_summary>"""
|
|
858
|
-
|
|
859
|
-
return summary
|
|
770
|
+
# MCP architectural limitation: MCP tools cannot call other MCP tools
|
|
771
|
+
# This is a fundamental constraint of the MCP protocol
|
|
772
|
+
return """<error>
|
|
773
|
+
MCP Architectural Limitation: This tool cannot directly call other MCP tools.
|
|
774
|
+
|
|
775
|
+
To get a search summary, please use the reflection-specialist agent instead:
|
|
776
|
+
1. Call the reflection-specialist agent
|
|
777
|
+
2. Ask it to provide a summary of search results for your query
|
|
778
|
+
|
|
779
|
+
Alternative: Call reflect_on_past directly and analyze the results yourself.
|
|
780
|
+
|
|
781
|
+
This limitation exists because MCP tools can only be orchestrated by the client (Claude),
|
|
782
|
+
not by other tools within the MCP server.
|
|
783
|
+
</error>"""
|
|
860
784
|
|
|
861
785
|
|
|
862
786
|
@mcp.tool()
|
|
@@ -869,47 +793,17 @@ async def get_more_results(
|
|
|
869
793
|
project: Optional[str] = Field(default=None, description="Search specific project only")
|
|
870
794
|
) -> str:
|
|
871
795
|
"""Get additional search results after an initial search (pagination support)."""
|
|
872
|
-
#
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
response_format="xml",
|
|
884
|
-
brief=False,
|
|
885
|
-
include_raw=False
|
|
886
|
-
)
|
|
887
|
-
|
|
888
|
-
# Parse and extract only the additional results
|
|
889
|
-
import re
|
|
890
|
-
|
|
891
|
-
# Find all result blocks
|
|
892
|
-
result_pattern = r'<r>.*?</r>'
|
|
893
|
-
all_results = re.findall(result_pattern, result, re.DOTALL)
|
|
894
|
-
|
|
895
|
-
# Get only the results after offset
|
|
896
|
-
additional_results = all_results[offset:offset+limit] if len(all_results) > offset else []
|
|
897
|
-
|
|
898
|
-
if not additional_results:
|
|
899
|
-
return """<more_results>
|
|
900
|
-
<message>No additional results found</message>
|
|
901
|
-
</more_results>"""
|
|
902
|
-
|
|
903
|
-
# Reconstruct response with only additional results
|
|
904
|
-
response = f"""<more_results>
|
|
905
|
-
<offset>{offset}</offset>
|
|
906
|
-
<count>{len(additional_results)}</count>
|
|
907
|
-
<results>
|
|
908
|
-
{''.join(additional_results)}
|
|
909
|
-
</results>
|
|
910
|
-
</more_results>"""
|
|
911
|
-
|
|
912
|
-
return response
|
|
796
|
+
# MCP architectural limitation: MCP tools cannot call other MCP tools
|
|
797
|
+
return """<error>
|
|
798
|
+
MCP Architectural Limitation: This tool cannot directly call other MCP tools.
|
|
799
|
+
|
|
800
|
+
To get more search results, please:
|
|
801
|
+
1. Call reflect_on_past directly with a higher limit parameter
|
|
802
|
+
2. Or use the reflection-specialist agent to handle pagination
|
|
803
|
+
|
|
804
|
+
This limitation exists because MCP tools can only be orchestrated by the client (Claude),
|
|
805
|
+
not by other tools within the MCP server.
|
|
806
|
+
</error>"""
|
|
913
807
|
|
|
914
808
|
|
|
915
809
|
@mcp.tool()
|