모델에게 필요한 정보와 컨텍스트를 제공, api의 get 엔드포인트와 유사. 데이터를 제공하지만, 계산을 수행하거나 부작용은 없도록 구성 필요
@mcp.resource("market://state")
def get_market_state() -> str:
"""Get the current market state
Returns:
str: the current market state
"""
return "the market is open"
@mcp.resource("market://stock,{symbol}")
def get_stock_price(symbol: str) -> str:
"""Get the current stock price
Args:
symbol(str): The symbol of the company to get the stock price for
Returns:
str: The current stock price
"""
return f"The current stock price for {symbol} is $100"
tool (@mcp.tool())
모델이 외부 시스템에서 작업을 수행할 수 있도록 함. 리소스와 달리 tool은 계산을 수행 (api의 post와 유사)
@mcp.tool()
def buy_stock(symbol: str, quantity:int) -> str:
"""Buys a stock for a given symbol and quantity
Args:
symbol (str): The symbol of the company to buy stock for
quantity (int): The quantity of stock to buy
Returns:
str: A string containing the result of the transaction
"""
return f"Bought {quantity} shares of {symbol}"
@mcp.tool()
def sell_stock(symbol: str, quantity:int) -> str:
"""Sell a stock for a given symbol and quantity
Args:
symbol (str): The symbol of the company to buy stock for
quantity (int): The quantity of stock to sell
Returns:
str: A string containing the result of the transaction
"""
return f"Sold {quantity} shares of {symbol}"
from fastmcp import FastMCP, Context
@mcp.tool()
async def long_task(files: list[str], ctx: Context) -> str:
"""
process multiple files with progress tracking
"""
for i, file in enumerate(files):
ctx.info(f"processing {file}")
await ctx.report_progress(i, len(files))
# read another resource if needed
data = await ctx.read_resource(f"file://{file}")
return "processing complete"
prompt(@mcp.prompt())
모델이 리소스와 tool을 활용하여 응답을 생성하는 문장 완성 기능 제공
context : tool과 리소스에 mcp 기능에 대한 엑세스를 제공
@mcp.prompt()
def analyze_stock(symbol: str, last_years_profit: str, company_info:str) -> str:
return f"""
You are a stock analyst. You are given a stock symbol and you need to analze the stock.
Here is the income statement:
{last_years_profit}
Here is the company info:
{company_info}
Here is the symbol:
{symbol}
Make sure to analyze the income statement and company info to give a detailed analysis of the stock.
Make a recommendation on whether to buy, sell, or hold the stock.
"""
github 소스 clone
bun 설치 (curl -fsSL https://bun.sh/install | bash)
bun setup
bun start (bun socket)
bunx cursor-talk-to-figma-mcp (새로운 터미널)
figma 설치 및 하단의 plugin 아이콘 클릭
cursor talk to figma mcp 플러그인 설치 후 use localhost 클릭 후 connect 클릭
또는 plugins -> development -> import plugin from manifest #(src/cursor_mcp_plugin/manifest.json 선택)
join_chennel: y59zgry8// 피그마 채널 y59zgry8 에 작업해줘 먼저 작성하여 디자인 변경 진행
share 버튼 클릭 copy link 클릭 후 cursor 채팅에 붙혀넣기 후 명령
디자인을 코드화
디자인 우클릭 -> copy paste as -> link to selection
github
용도
기존 http 프로토콜로 웹생태계를 연동했다면, 모델활용 생태계에 접근할 인터페이스로 활용
규격화된 정보나 트랜드 컨텐츠를 만들어 내는 것과 달리 인공지능 끼리 데이터를 공유하는 서버로 데이터 관리
구분 (2025-04-03 기준)
host : mcp를 통해 접속하려는 도구 (cursor ai, claude desktop, lang graph..)
client(mcp adapter) : server와 연결을 유지하는 프로토콜 클라이언트 (host와 server 간에 연결을 위한 중개자)
server : 표준화된 모델 컨텍스트 프로토콜을 통해 각각 특정 기능을 노출하는 경량 프로그램