MCP 작동원리 v2
호스트는 설치되어 있는 툴 목록을 미리 생성
[SYSTEM] Starting MCP client...
[SYSTEM] Available tools: ['read_query', 'write_query', 'create_table', 'list_tables', 'describe_table', 'append_insight']
[SYSTEM] MCP client successfully initialized사용자가 질문을 작성
Enter your prompt (or 'quit' to exit): show tables in database.“시스템 프롬프트 + 사용자 질문 + 사용가능한 툴목록” 을 합쳐서 모델에 입력
[MODEL INPUT]
system: You are a helpful assistant capable of accessing external functions and engaging in casual chat. Use the responses from these function calls to provide accurate and informative answers. The answers should be natural and hide the fact that you are using tools to access real-time information. Guide the user about available tools and their capabilities. Always utilize tools to access real-time information when required. Engage in a friendly manner to enhance the chat experience.
# Tools
read_query: Execute a SELECT query on the SQLite database
- write_query: Execute an INSERT, UPDATE, or DELETE query on the SQLite database
- create_table: Create a new table in the SQLite database
- describe_table: Get the schema information for a specific table
- append_insight: Add a business insight to the memo
# Notes
- Ensure responses are based on the latest information available from function calls.
- Maintain an engaging, supportive, and friendly tone throughout the dialogue.
- Always highlight the potential of available tools to assist users comprehensively.
user: show tables in database.
tools: ['read_query', 'write_query', 'create_table', 'describe_table', 'append_insight']모델은 툴 실행을 위한 명령 생성
[MODEL OUTPUT]
content:
tool_calls: [ChatCompletionMessageToolCall(id='call_e9lkpyeg', function=Function(arguments='{"query":"SELECT name FROM sqlite_master WHERE type=\'table\';"}', name='read_query'), type='function', index=0)]호스트(MCP 클라이언트) 는 생성된 명령을 실제 MCP 서버에 전달
[TOOL INPUT] read_query: {
"query": "SELECT name FROM sqlite_master WHERE type='table';"
}MCP 서버는 결과 반환
[TOOL OUTPUT] read_query: [{'name': 'tbl_test'}]“시스템 프롬프트 + 사용자 질문 + 사용가능한 툴목록 + 툴이 제공한 결과” 을 합쳐서 모델에 2차 입력
[MODEL INPUT WITH TOOL RESULTS]
system: You are a helpful assistant capable of accessing external functions and engaging in casual chat. Use the responses from these function calls to provide accurate and informative answers. The answers should be natural and hide the fact that you are using tools to access real-time information. Guide the user about available tools and their capabilities. Always utilize tools to access real-time information when required. Engage in a friendly manner to enhance the chat experience.
# Tools
read_query: Execute a SELECT query on the SQLite database
- write_query: Execute an INSERT, UPDATE, or DELETE query on the SQLite database
- create_table: Create a new table in the SQLite database
- describe_table: Get the schema information for a specific table
- append_insight: Add a business insight to the memo
# Notes
- Ensure responses are based on the latest information available from function calls.
- Maintain an engaging, supportive, and friendly tone throughout the dialogue.
- Always highlight the potential of available tools to assist users comprehensively.
user: show tables in database.
assistant:
tool: "[{'name': 'tbl_test'}]"모델은 답변을 작성하여 출력
[MODEL FINAL OUTPUT]
content: It looks like you have a table named `tbl_test` in your SQLite database! If you want to see information about the schema of this table or need help with manipulating it, feel free to ask. I can assist with queries and other operations on tables. What would you like to do next?아이디어가 재미있네요.
모델을 추가학습하지 않고도 MCP 명령을 생성하고 결과를 이용한다는 아이디어.