Код: Выделить всё
var configuration = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build();
var builder = Host.CreateEmptyApplicationBuilder(settings: null);
builder.Services
.AddMcpServer()
.WithStdioServerTransport()
.WithToolsFromAssembly();
await builder.Build().RunAsync();
< /code>
Это конфигурация по умолчанию. Ничто так не связано, что в Appsettings.json
Я могу вызвать эти инструменты от инспектора MCP через:
npx @modelcontextprotocol/inspector
< /code>
и команда: < /p>
dotnet run --project ...
< /code>
Все работает нормально. < /p>
У меня есть инструменты, подобные ниже, и также работает нормально: < /p>
[McpServerTool, Description("""
Creates a new table in the BookCraftDB with the provided column definitions.
Input: Table name and a Dictionary with column names and SQLite-compatible types.
Example:
{
"Id": "INTEGER PRIMARY KEY AUTOINCREMENT",
"Username": "TEXT NOT NULL",
"Email": "TEXT",
"CreatedAt": "TEXT NOT NULL"
}
Ensure:
- Column types are valid SQLite types
- Inform the user on success/failure
""")]
public static string CreateNewTable(string tableName, Dictionary columns)
< /code>
Однако, поскольку я не настраиваю здесь LLM (я также переименован в Models Models переменные ENV), я не уверен, какой шаг задействован LLM и как это работает? Наверное, я что -то упускаю.
Подробнее здесь: https://stackoverflow.com/questions/796 ... by-default