feat(mcp): Dabit.Mcp 초기 공개 (리네임 + colors 수정 + scroll 검증)
- refactor: DabitChe.Mcp → Dabit.Mcp (namespace, csproj, exe 모두) - fix: display_message colors를 쉼표 구분 문자열로 변경 (ModelContextProtocol 1.3.0 배열 바인딩 버그 우회) - docs: scroll 4방향(left/right/up/down) 실기 검증 완료 (DIBD600T V3.6.1) 20 도구 (읽기 4 + 콘텐츠 2 + 설정 14), stdio 전송, Windows exe. 실기 검증: scroll/fill_screen 8색/display_message 글자별색 모두 정상. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
46
Dabit.Mcp/Config/McpConnectionSettings.cs
Normal file
46
Dabit.Mcp/Config/McpConnectionSettings.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using DibdProtocol.Transport;
|
||||
|
||||
namespace Dabit.Mcp.Config;
|
||||
|
||||
/// <summary>
|
||||
/// MCP 서버가 붙을 전광판 연결 설정. 환경변수(DABIT_*)에서 읽는다.
|
||||
/// Claude Desktop이 claude_desktop_config.json의 env로 주입하는 것을 기본으로 한다
|
||||
/// (서버 프로세스의 작업 디렉터리가 불확실하므로 파일보다 환경변수가 견고).
|
||||
/// </summary>
|
||||
public sealed record McpConnectionSettings
|
||||
{
|
||||
public TransportType ConnectType { get; init; } = TransportType.TcpClient;
|
||||
public string PortName { get; init; } = "COM1";
|
||||
public int BaudRate { get; init; } = 9600;
|
||||
public string Host { get; init; } = "192.168.0.201";
|
||||
public int Port { get; init; } = 5000;
|
||||
public int ResponseLatencyMs { get; init; } = 1000;
|
||||
|
||||
/// <summary>환경변수에서 설정을 읽는다. 누락 항목은 기본값.</summary>
|
||||
public static McpConnectionSettings FromEnvironment()
|
||||
{
|
||||
static string? Env(string key) => Environment.GetEnvironmentVariable(key);
|
||||
|
||||
var transport = (Env("DABIT_TRANSPORT") ?? "").Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"serial" => TransportType.Serial,
|
||||
"tcp" or "tcpclient" => TransportType.TcpClient,
|
||||
_ => TransportType.TcpClient,
|
||||
};
|
||||
|
||||
return new McpConnectionSettings
|
||||
{
|
||||
ConnectType = transport,
|
||||
PortName = Env("DABIT_COM") ?? "COM1",
|
||||
BaudRate = int.TryParse(Env("DABIT_BAUD"), out var b) ? b : 9600,
|
||||
Host = Env("DABIT_HOST") ?? "192.168.0.201",
|
||||
Port = int.TryParse(Env("DABIT_PORT"), out var p) ? p : 5000,
|
||||
ResponseLatencyMs = int.TryParse(Env("DABIT_RESPONSE_LATENCY"), out var r) ? r : 1000,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>사람이 읽을 연결 요약 문자열.</summary>
|
||||
public string Describe() => ConnectType == TransportType.Serial
|
||||
? $"Serial {PortName} @ {BaudRate}bps (timeout {ResponseLatencyMs}ms)"
|
||||
: $"TcpClient {Host}:{Port} (timeout {ResponseLatencyMs}ms)";
|
||||
}
|
||||
Reference in New Issue
Block a user