MCPcopy Index your code
hub / github.com/github/github-mcp-server / generateToolsDoc

Function generateToolsDoc

cmd/github-mcp-server/generate_docs.go:172–216  ·  view source on GitHub ↗
(r *inventory.Inventory)

Source from the content-addressed store, hash-verified

170}
171
172func generateToolsDoc(r *inventory.Inventory) string {
173 tools := r.ToolsForRegistration(context.Background())
174 if len(tools) == 0 {
175 return ""
176 }
177
178 var buf strings.Builder
179 var toolBuf strings.Builder
180 var currentToolsetID inventory.ToolsetID
181 var currentToolsetIcon string
182 firstSection := true
183
184 writeSection := func() {
185 if toolBuf.Len() == 0 {
186 return
187 }
188 if !firstSection {
189 buf.WriteString("\n\n")
190 }
191 firstSection = false
192 sectionName := formatToolsetName(string(currentToolsetID))
193 icon := octiconImg(currentToolsetIcon)
194 if icon != "" {
195 icon += " "
196 }
197 fmt.Fprintf(&buf, "<details>\n\n<summary>%s%s</summary>\n\n%s\n\n</details>", icon, sectionName, strings.TrimSuffix(toolBuf.String(), "\n\n"))
198 toolBuf.Reset()
199 }
200
201 for _, tool := range tools {
202 // When toolset changes, emit the previous section
203 if tool.Toolset.ID != currentToolsetID {
204 writeSection()
205 currentToolsetID = tool.Toolset.ID
206 currentToolsetIcon = tool.Toolset.Icon
207 }
208 writeToolDoc(&toolBuf, tool)
209 toolBuf.WriteString("\n\n")
210 }
211
212 // Emit the last section
213 writeSection()
214
215 return buf.String()
216}
217
218func writeToolDoc(buf *strings.Builder, tool inventory.ServerTool) {
219 // Tool name (no icon - section header already has the toolset icon)

Callers 1

generateReadmeDocsFunction · 0.85

Calls 5

formatToolsetNameFunction · 0.85
octiconImgFunction · 0.85
writeToolDocFunction · 0.85
ToolsForRegistrationMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected