MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / CawToolKit

Class CawToolKit

codewiki/src/be/caw_toolkit.py:74–316  ·  view source on GitHub ↗

MCP tool server exposing CodeWiki tools to a caw Agent.

Source from the content-addressed store, hash-verified

72
73
74class CawToolKit(
75 ToolKit,
76 server_name="codewiki_tools",
77 display_name="CodeWiki Tools",
78):
79 """MCP tool server exposing CodeWiki tools to a caw Agent."""
80
81 def __init__(
82 self,
83 deps: CodeWikiDeps,
84 backend: "CawBackend",
85 allow_subagent: bool,
86 ) -> None:
87 self._deps = deps
88 self._backend = backend
89 self._allow_subagent = allow_subagent
90
91 # ------------------------------------------------------------------
92 # Tool: read_code_components
93 # ------------------------------------------------------------------
94
95 @tool(
96 description=(
97 "Read the source code of the given component ids. "
98 "component_ids is a list of strings like "
99 "['sweagent/types.py::AgentRunResult', 'auth/middleware.py::verify_token'] "
100 "where the part before '::' is the file path and the part after is the component name."
101 )
102 )
103 async def read_code_components(self, component_ids: list[str]) -> str:
104 results = []
105 for cid in component_ids:
106 if cid not in self._deps.components:
107 results.append(f"# Component {cid} not found")
108 else:
109 results.append(
110 f"# Component {cid}:\n"
111 f"{self._deps.components[cid].source_code.strip()}\n\n"
112 )
113 return "\n".join(results)
114
115 # ------------------------------------------------------------------
116 # Tool: str_replace_editor
117 # Reuses the EditTool implementation + Mermaid validator from the
118 # existing module so behavior matches the pydantic-ai path exactly.
119 # ------------------------------------------------------------------
120
121 @tool(
122 description=(
123 "Custom editing tool for viewing, creating and editing files.\n"
124 "* If `path` is a file, `view` displays the result of applying `cat -n`. "
125 "If `path` is a directory, `view` lists non-hidden files and directories up to 2 levels deep.\n"
126 "* The `create` command cannot be used if the specified `path` already exists as a file.\n"
127 "* If a `command` generates a long output, it will be truncated and marked with `<response clipped>`.\n"
128 "* The `undo_edit` command will revert the last edit made to the file at `path`.\n"
129 "* Only `view` command is allowed when `working_dir` is `repo`."
130 )
131 )

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected