MCPcopy Create free account
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 return value
73
74
75class CawToolKit(
76 ToolKit,
77 server_name="codewiki_tools",
78 display_name="CodeWiki Tools",
79):
80 """MCP tool server exposing CodeWiki tools to a caw Agent."""
81
82 def __init__(
83 self,
84 deps: CodeWikiDeps,
85 backend: CawBackend,
86 allow_subagent: bool,
87 ) -> None:
88 self._deps = deps
89 self._backend = backend
90 self._allow_subagent = allow_subagent
91
92 # ------------------------------------------------------------------
93 # Tool: read_code_components
94 # ------------------------------------------------------------------
95
96 @tool(
97 description=(
98 "Read the source code of the given component ids. "
99 "component_ids is a list of strings like "
100 "['sweagent/types.py::AgentRunResult', 'auth/middleware.py::verify_token'] "
101 "where the part before '::' is the file path and the part after is the component name."
102 )
103 )
104 async def read_code_components(self, component_ids: list[str]) -> str:
105 results = []
106 for cid in component_ids:
107 if cid not in self._deps.components:
108 results.append(f"# Component {cid} not found")
109 else:
110 results.append(
111 f"# Component {cid}:\n{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 (plus `.github`) 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