persona-mcp
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"persona-server": {
"args": [
"-m",
"src.main"
],
"command": "python3",
"cwd": "/Users/seodong-ug/Desktop/persona_mcp"
}
}
}
服务介绍
Persona MCP Server
AI FGI (Focus Group Interview) MCP (Model Context Protocol) .
MCP ?
MCP (Model Context Protocol) AI .
MCP
- (Tools): AI
- (Resources): AI
- (Prompts):
MCP
Persona MCP Server FastMCP , :
- ** (stdio) **: MCP JSON-RPC
- ** **:
asyncio - ** **: Pydantic /
?
MCP ** FGI ** . :
1.
-
AI - MBTI , , ,
- (, , , )
2. FGI
- (, , , , , )
- AI
-
3.
- " "
-
( -3) - SS, S, A, B, C
4.
- /
5.
- LLM ( )
MCP Client (Cursor AI, Claude Desktop )
(Cursor AI)
JSON-RPC (stdio)
Persona MCP Server
FastMCP Framework
- Tool Registration
- Request/Response Handling
Tool Implementations
- FGI Tools (fgi_tools.py)
- Predict (predict.py)
- Insights (insights.py)
- Freshness (freshness.py)
- Query (query.py)
- Sample Data (sample_data.py)
Database Layer (SQLAlchemy)
- Persona Model
- FGISurvey Model
- FGIResponse Model
SQLite Database
(data/fgi.db)
Groq LLM API
(AI )
- FastMCP: MCP
- SQLAlchemy: ORM
- Groq API: LLM
- Pydantic:
- ** **:
1.
** : !**
. .
, .
#
questions = get_basic_profile_questions_tool()
** :**
age_range: () - 10, 20 , 20 , 30 , 30 , 40gender: () - , , ,location: () - , , , , , , ,occupation_category: () - IT/, , , , , ,income_range: () - 200 , 200-300, 300-500, 500 ,
** :** age_range, gender, location, occupation_category (4)
** :** income_range (1)
** :**
get_basic_profile_questions_tool()update_basic_profile_tool()
.
#
check_basic_profile_tool()
#
check_basic_profile_tool(persona_id="persona_123")
** :**
is_complete: (bool)missing_fields:message:persona_id: ID ( None)
.
#
update_basic_profile_tool(
persona_id="persona_123",
profile_data={
"age_range": "20 ", #
"gender": "", #
"location": "", #
"occupation_category": "IT/", #
"income_range": "300-500" # ,
}
)
:
profile_dataget_basic_profile_questions_tool().- ** 4(
age_range,gender,location,occupation_category) .** income_range.-
( 25). - ** , .**
(AI )
#
predict_persona_tool(
responses=[
{"question_id": "q1", "answer": " ..."},
{"question_id": "q2", "answer": " ..."}
],
user_id="user_123"
)
** :**
- MBTI
- MBTI
2. FGI
#
create_fgi_survey_tool(
category="technology", # technology, lifestyle, culture, fashion, food, general
persona_id="persona_123" #
)
** :**
technology:lifestyle:culture: /fashion:food:general:
#
generate_next_question_tool(
survey_id="survey_123",
previous_qa=[
{"question": " ?", "answer": "AI "},
{"question": " ?", "answer": " "}
],
category="technology",
max_questions=10 # :
)
:
- AI
- (
info_completeness) - (
is_final)
#
submit_fgi_response_tool(
persona_id="persona_123",
survey_id="survey_123",
responses=[
{"question_id": "q1", "answer": " "},
{"question_id": "q2", "answer": " "}
]
)
3.
" " .
** :**
- : 25
- : 10-50 ( )
- : 50-100
** :**
-
: -3 - 0
| SS | 500 | - |
| S | 300-499 | - |
| A | 200-299 | - |
| B | 100-199 | - |
| C | 50-99 | - |
| F | 0-49 | - |
#
check_freshness_tool(persona_id="persona_123")
** :**
- (SS, S, A, B, C, F)
4.
# /
analyze_preference_tool(
query=" ",
category="fashion", #
age_range="20 ", #
gender="", #
location="", #
limit=20
)
** :**
- /
#
get_trend_insights_tool(
topic="",
persona_filters={
"age_range": "20",
"gender": ""
},
min_freshness=100 #
)
#
search_responses_tool(
keyword="",
category="fashion",
limit=20
)
5.
get_persona_tool(persona_id="persona_123")
** :**
- (, , )
- MBTI
- ( , )
list_personas_tool(
age_range="20 ",
gender="",
location="",
occupation_category="IT/",
mbti_type="INTJ",
min_freshness=200,
limit=50
)
compare_personas_tool(
persona_id1="persona_123",
persona_id2="persona_456"
)
** :**
- MBTI
6.
get_statistics_tool()
** :**
- MBTI
get_persona_survey_history_tool(persona_id="persona_123")
7.
generate_sample_personas_tool(
count=50,
use_llm=True # False ( )
)
generate_sample_surveys_tool(
persona_count=20,
responses_per_persona=2,
use_llm=True
)
generate_all_sample_data_tool(
persona_count=50,
responses_per_persona=2,
use_llm=True
)
1.
pip install -r requirements.txt
pyproject.toml :
pip install -e .
2.
.env :
# Groq API (LLM )
GROQ_API_KEY=your_groq_api_key_here
# URL (, : sqlite:///data/fgi.db)
DATABASE_URL=sqlite:///data/fgi.db
# (, : INFO)
LOG_LEVEL=INFO
Groq API :
- Groq Console
- API Keys
.env
3.
:
python -m src.main
data/fgi.db ( ).
** : **
:
get_basic_profile_questions_tool(),update_basic_profile_tool()
4.
python -m src.main
MCP
MCP (Cursor AI, Claude Desktop ) .
Cursor AI
-
**Cursor **
Cmd + ,(Mac)Ctrl + ,(Windows/Linux)- "MCP"
-
**MCP **
:
{ "mcpServers": { "persona-server": { "command": "python3", "args": ["-m", "src.main"], "cwd": "/Users/seodong-ug/Desktop/persona_mcp" } } }:
cwd. -
**Cursor **
- Cursor
-
- " "
Claude Desktop
claude_desktop_config.json :
{
"mcpServers": {
"persona-server": {
"command": "python3",
"args": ["-m", "src.main"],
"cwd": "/Users/seodong-ug/Desktop/persona_mcp"
}
}
}
API
health |
||
get_tool_definitions |
get_basic_profile_questions_tool |
||
check_basic_profile_tool |
(persona_id ) | |
update_basic_profile_tool |
persona_id, profile_data |
|
predict_persona_tool |
responses |
|
get_persona_tool |
persona_id |
|
list_personas_tool |
( ) | |
compare_personas_tool |
persona_id1, persona_id2 |
|
check_freshness_tool |
persona_id |
FGI
create_fgi_survey_tool |
category |
|
generate_next_question_tool |
survey_id, previous_qa |
|
submit_fgi_response_tool |
persona_id, survey_id, responses |
|
get_persona_survey_history_tool |
persona_id |
analyze_preference_tool |
query |
|
get_trend_insights_tool |
topic |
|
search_responses_tool |
keyword |
|
get_statistics_tool |
generate_sample_personas_tool |
() | |
generate_sample_surveys_tool |
() | |
generate_all_sample_data_tool |
() |
Persona ()
{
"id": "persona_123", # ID
"user_id": "user_123", # ID ()
"freshness_score": 250.0, #
"last_updated": "2024-01-15T10:30:00", #
"created_at": "2024-01-10T09:00:00", #
#
"age_range": "20 ",
"gender": "",
"location": "",
"occupation_category": "IT/",
"income_range": "300-500",
#
"interests": ["", "AI", ""],
"personality_traits": ["", " "],
"values": ["", ""],
"lifestyle": " ",
# MBTI
"mbti_type": "INTJ",
"mbti_dimensions": {
"E_I": "(I) - ",
"S_N": "(N) - ",
"T_F": "(T) - ",
"J_P": "(J) - "
},
"mbti_confidence": 85 # 0-100
}
FGISurvey ()
{
"id": "survey_123",
"category": "technology",
"questions": [
{
"id": "q1",
"text": " ?",
"type": "open"
}
],
"created_at": "2024-01-15T10:00:00",
"news_source": null #
}
FGIResponse ()
{
"id": "response_123",
"persona_id": "persona_123",
"survey_id": "survey_123",
"responses": [
{
"question_id": "q1",
"answer": "AI "
}
],
"submitted_at": "2024-01-15T10:30:00"
}
1:
# 1.
questions = get_basic_profile_questions_tool()
# :
# {
# "questions": {
# "age_range": {"text": " ", "type": "choice", "options": [...]},
# "gender": {"text": " ", "type": "choice", "options": [...]},
# ...
# }
# }
# 2. ()
# UI .
# 3.
update_basic_profile_tool(
persona_id="persona_new_001",
profile_data={
"age_range": "20 ", # questions["questions"]["age_range"]["options"]
"gender": "", # questions["questions"]["gender"]["options"]
"location": "", # questions["questions"]["location"]["options"]
"occupation_category": "IT/" # questions["questions"]["occupation_category"]["options"]
# income_range
}
)
# 4.
survey = create_fgi_survey_tool(
category="technology",
persona_id="persona_new_001"
)
# 5.
submit_fgi_response_tool(
persona_id="persona_new_001",
survey_id=survey["survey_id"],
responses=[
{
"question_id": survey["questions"][0]["id"],
"answer": "AI . ChatGPT AI ."
}
]
)
# 6.
next_q = generate_next_question_tool(
survey_id=survey["survey_id"],
previous_qa=[
{
"question": survey["questions"][0]["text"],
"answer": "AI ..."
}
],
category="technology"
)
# 7. - ...
# 8.
persona = predict_persona_tool(
responses=[
{"question_id": "q1", "answer": "..."},
{"question_id": "q2", "answer": "..."}
]
)
2:
# 20
preference = analyze_preference_tool(
query=" ",
category="fashion",
age_range="20",
gender="",
location="",
limit=30
)
#
print(preference["insights"])
# - " "
# - " "
# - " "
3:
#
trends = get_trend_insights_tool(
topic="",
persona_filters={
"age_range": "20",
"gender": ""
},
min_freshness=150
)
#
print(trends["summary"])
4:
# 50 (LLM )
generate_sample_personas_tool(count=50, use_llm=True)
# 20 2
generate_sample_surveys_tool(
persona_count=20,
responses_per_persona=2,
use_llm=True
)
#
generate_all_sample_data_tool(
persona_count=50,
responses_per_persona=2,
use_llm=False # ( )
)
5:
#
comparison = compare_personas_tool(
persona_id1="persona_123",
persona_id2="persona_456"
)
#
print(comparison["similarities"])
print(comparison["differences"])
#
stats = get_statistics_tool()
print(f" : {stats['total_personas']}")
print(f" : {stats['avg_freshness']}")
print(f"MBTI : {stats['mbti_distribution']}")
- FastMCP: MCP
- SQLAlchemy: ORM
- Groq API: LLM
- Pydantic:
- Python-dotenv:
- SQLite: (PostgreSQL )
persona_mcp/
src/
main.py # MCP
db/
database.py #
models.py # SQLAlchemy
tools/
persona/
fgi_tools.py # FGI
predict.py #
freshness.py #
insights.py #
query.py #
sample_data.py #
utils/
cache.py #
credentials.py # API
data/
fgi.db # SQLite
cache/ #
requirements.txt # Python
pyproject.toml #
README.md #
-
**Groq API **: LLM Groq API . CRUD , .
-
** **: . .
-
****: , 12 . .
-
****: SQLite ,
DATABASE_URLPostgreSQL, MySQL .
.
!
.