Skip to content

Commit ea81960

Browse files
refactor: remove GetBookMetadata tool; fix BookContentTool foreach->Select
- Remove GetBookMetadata() MCP tool and trim BookMetadata class to SiteUrl only - Fix PR #876 feedback: refactor foreach+clone into codeLines.Select(line => line.CloneNode(deep:true)) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 65bddcb commit ea81960

3 files changed

Lines changed: 1 addition & 46 deletions

File tree

EssentialCSharp.Web/Tools/BookContentTool.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,8 @@ private static void ExtractNodeContent(HtmlNode node, StringBuilder sb)
401401
var codeLines = node.SelectNodes(".//div[contains(@class,'code-line')]");
402402
if (codeLines is not null)
403403
{
404-
foreach (var line in codeLines)
404+
foreach (var lineClone in codeLines.Select(line => line.CloneNode(deep: true)))
405405
{
406-
// Clone to avoid mutating the live HtmlDocument DOM
407-
var lineClone = line.CloneNode(deep: true);
408406
var lineNumberSpan = lineClone.SelectSingleNode(".//span[contains(@class,'code-line-number')]");
409407
lineNumberSpan?.Remove();
410408
sb.AppendLine(HtmlEntity.DeEntitize(lineClone.InnerText));

EssentialCSharp.Web/Tools/BookSearchTool.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@
99

1010
namespace EssentialCSharp.Web.Tools;
1111

12-
// Book metadata constants — update here when edition changes.
1312
file static class BookMetadata
1413
{
15-
public const string Title = "Essential C#";
16-
public const string Edition = "9th Edition";
17-
public const string CSharpVersion = "C# 13.0";
18-
public const string Authors = "Mark and Benjamin Michaelis";
19-
public const string Publisher = "Addison-Wesley Professional";
20-
public const string Isbn13 = "978-0-13-576056-5";
2114
public const string SiteUrl = "https://essentialcsharp.com";
2215
}
2316

@@ -175,23 +168,6 @@ public string GetDirectContentUrl(
175168
$"URL: {url}";
176169
}
177170

178-
[McpServerTool(Title = "Get Book Metadata", ReadOnly = true, Destructive = false, Idempotent = true, OpenWorld = false),
179-
Description("Get citation-quality metadata for the Essential C# book: title, authors, edition, C# version covered, ISBN, publisher, and website URL. Use this when generating citations or when asked which edition or C# version the book covers.")]
180-
public string GetBookMetadata()
181-
{
182-
return $"""
183-
# {BookMetadata.Title} — Book Metadata
184-
185-
**Title:** {BookMetadata.Title}
186-
**Edition:** {BookMetadata.Edition}
187-
**C# Version:** {BookMetadata.CSharpVersion}
188-
**Authors:** {BookMetadata.Authors}
189-
**Publisher:** {BookMetadata.Publisher}
190-
**ISBN-13:** {BookMetadata.Isbn13}
191-
**Website:** {BookMetadata.SiteUrl}
192-
""";
193-
}
194-
195171
[McpServerTool(Title = "Lookup Concept", ReadOnly = true, Destructive = false, Idempotent = true, OpenWorld = false),
196172
Description("Find all sections in the Essential C# book that cover a specific C# concept. Combines section heading search with semantic vector search (when available) to give broad coverage. Returns section slugs, chapter numbers, and direct links.")]
197173
public async Task<string> LookupConcept(

EssentialCSharp.Web/Views/McpSetup/Index.cshtml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -591,25 +591,6 @@
591591
</div>
592592
</details>
593593

594-
<details class="card mb-2">
595-
<summary class="card-header d-flex align-items-center gap-2" style="cursor:pointer;list-style:none">
596-
<span class="details-chevron">&#9656;</span>
597-
<span class="font-monospace fw-semibold">get_book_metadata</span>
598-
<span class="text-muted small ms-auto">Citation-quality book info</span>
599-
</summary>
600-
<div class="card-body">
601-
<p class="card-text">
602-
Returns title, authors, edition, C# version covered, ISBN, publisher, and website URL.
603-
Useful when the AI needs to cite the book or answer "which edition is this?"
604-
</p>
605-
<dl class="row mb-0 small">
606-
<dt class="col-sm-3">Input</dt>
607-
<dd class="col-sm-9">None</dd>
608-
<dt class="col-sm-3">Returns</dt>
609-
<dd class="col-sm-9">Title, 9th Edition, C# 13, authors, ISBN-13, publisher, URL</dd>
610-
</dl>
611-
</div>
612-
</details>
613594

614595
</section>
615596

0 commit comments

Comments
 (0)