Adds ModelContextProtocol.AspNetCore and registers AddMcpServer with WithListToolsHandler/WithCallToolHandler rather than 45 attribute methods, so both handlers resolve the scoped NovelAgentToolset per request and reuse its hand-built schemas directly instead of fighting the SDK's delegate-based schema inference. NovelMcpTools (src/Novelly.Api/Mcp/) is the adapter: it injects a required novelId property into the advertised schema for tools that need one and extracts it back out at call time, since the web agent gets novelId ambiently from its route but an MCP client has no route to supply it from. /mcp inherits auth from the existing fallback policy (cookie or X-Novelly-Api-Key) by adding no authorization metadata of its own — chaining .RequireAuthorization() would apply the default, cookie-only policy instead and break the API key. Verified end to end against a running instance: initialize advertises capabilities.tools, tools/list returns all 45 with novelId injected only where needed, tool errors map to result.isError rather than a JSON-RPC error, and a write (create_tag) round-trips correctly with the service user's identity intact.
32 lines
1.4 KiB
XML
32 lines
1.4 KiB
XML
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
|
|
<ItemGroup>
|
|
<ProjectReference Include="..\Novelly.ServiceDefaults\Novelly.ServiceDefaults.csproj" />
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<PackageReference Include="Anthropic" Version="12.39.0" />
|
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="10.0.10" />
|
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.10" />
|
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.10">
|
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
<PrivateAssets>all</PrivateAssets>
|
|
</PackageReference>
|
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.10" />
|
|
<PackageReference Include="Microsoft.OpenApi" Version="2.11.0" />
|
|
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="2.1.0" />
|
|
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
|
|
<PackageReference Include="Serilog.Settings.Configuration" Version="10.0.1" />
|
|
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="3.0.5" />
|
|
</ItemGroup>
|
|
|
|
<PropertyGroup>
|
|
<TargetFramework>net10.0</TargetFramework>
|
|
<Nullable>enable</Nullable>
|
|
<LangVersion>latest</LangVersion>
|
|
<ImplicitUsings>enable</ImplicitUsings>
|
|
<UserSecretsId>fb455630-f631-46bb-9c60-0deaf01c593e</UserSecretsId>
|
|
</PropertyGroup>
|
|
|
|
</Project>
|